En left join är korrekt, men du behöver för types att vara först:
SELECT DISTINCT types.type, owners.name, owners.city
FROM tbl_pet_types types LEFT JOIN
tbl_pet_owners owners
ON owners.pet = types.pet
WHERE types.type IN ('mammal', 'fish', 'amphibian', 'seacreature');
Eftersom WHERE klausul hänvisar endast till tbl_pet_types , det ändras inte.
Hur left join fungerar är enkelt:Det håller alla rader i den första tabell. Omatchade kolumner i den andra blir NULL .
EDIT:
Om du har en lista över typer som inte finns i tbl_pet_types , då behöver du en left join med alla värden i en härledd tabell:
SELECT DISTINCT tt.type, po.name, po.city
FROM (SELECT 'mammal' as type UNION ALL
SELECT 'fish' as type UNION ALL
SELECT 'amphibian' as type UNION ALL
SELECT 'seacreature' as type
) tt left join
tbl_pet_types pt
ON pt.type = tt.type LEFT JOIN
tbl_pet_owners po
ON po.pet = pt.pet;