For example, I have the following tables:
animal
-----------------------
animal_id | animal_name
-----------------------
owners
-----------------------
owner_id | owner_name
-----------------------
owners_animals
--------------------
owner_id | animal_id
--------------------
I want to find the animals with no owners so I do the query:
select animal_name
from (select * from animals) as a
left join (select * from owners_animals) as o on (a.animal_id = o.animal_id)
where owner_id is NULL
Is this way of filtering data using a join acceptable and safe? With the same schema, is there a better alternative to get the same result?