Mysql Query:
SELECT *
FROM `pet_info` LEFT JOIN
`lostpets`
ON `pet_info`.`id` = `lostpets`.`petid` LEFT JOIN
`pet_images`
ON `pet_info`.`id`
I think you intend:
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
`cat_breeds`
ON `cat_breeds`.`id` = `pet_info`.`pet_breed` AND
`pet_info`.`pet_cat` = 2 LEFT JOIN
`dog_breeds`
ON `dog_breeds`.`id` = `pet_info`.`pet_breed` AND
`pet_info`.`pet_cat` = 1
WHERE `pet_info`.`pet_user_id` = 581;
Notes:
SELECT *
, you should explicitly choose the columns you want. The different tables have columns with the same name.SELECT
to combine columns from cat_breeds
and dog_breeds
, such as COALESCE(cat_breeds.col1, dog_breeds.col1) as col1
.