mysql结果行多于表行

时间:2017-04-18 18:01:10

标签: mysql

SQL查询:

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 `dog_breeds` ON `dog_breeds`.`id` = CASE WHEN `pet_info`.`pet_cat` = 1 THEN `dog_breeds`.`id` END
LEFT JOIN `cat_breeds` ON `cat_breeds`.`id` = CASE WHEN `pet_info`.`pet_cat` = 2 THEN `cat_breeds`.`id` END

pet_info表中只有3行,但在运行查询时,它显示的行数超过183行。 cat_breeds和dog_breeds表中有超过183行。为什么它上传183行请帮助我如何显示pet_info表中的所有行。

0 个答案:

没有答案