gpt4 book ai didi

MYSQL 连接错误。如何解决?

转载 作者:行者123 更新时间:2023-11-29 19:06:35 25 4
gpt4 key购买 nike

MYSQL查询:

SELECT * FROM `pet_info` LEFT JOIN `lostpets` ON `pet_info`.`id` = `lostpets`.`petid` LEFT JOIN `pet_images` ON `pet_info`.`id` = `pet_images`.`petid` LEFT JOIN ON `pet_info`.`pet_cat` CASE WHEN `pet_info`.`pet_cat` = 1 THEN `dog_breeds`.`id` WHEN `pet_info`.`pet_cat` = 2 THEN `cat_breeds`.`id` END WHERE `pet_info`.`pet_user_id` = 581

错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON `pet_info`.`pet_cat` CASE WHEN `pet_info`.`pet_cat` = 1 THEN `do' at line 7

为什么出现错误,请帮助我。我可以解决这个错误吗?

最佳答案

这是您的查询的格式化版本,突出显示了一些错误。

SELECT * 
FROM pet_info p
LEFT
JOIN lostpets l
ON p.id = l.petid
LEFT
JOIN pet_images i
ON p.id = i.petid
LEFT
JOIN !! ERROR 1
ON p.pet_cat !! ERROR 2
CASE WHEN p.pet_cat = 1
THEN d.id !! ERROR 3
WHEN p.pet_cat = 2
THEN c.id END !! ERROR 4
WHERE p.pet_user_id = 581

关于MYSQL 连接错误。如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43439450/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com