I have two queries below that i'm sure can be combined in to one but i'm not sure how.
I want to get the first_name and email columns for every user, but I also want to get the associated pet_type and pet_breed from the first advert record if they have one. The advert record only contains a breed_id which is then linked to pet_breeds table to get the pet_type and pet_breed. I dont need to return the breed_id in the results, just the pet_type and pet_breed. If no associated advert record exists for a user then I want the pet_breed and pet_type to return the text 'None'.
SELECT users.first_name, users.email,
(SELECT adverts.breed_id AS breed
FROM adverts
WHERE adverts.user_id = users.user_id
LIMIT 1)
FROM users
Second Query
SELECT pet_type, pet_breed
FROM pet_breeds
WHERE breed_id = breed