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 animals without owners, so I make a request:
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 method of filtering data using a connection acceptable and safe? With the same scheme, is there a better alternative to get the same result?
source share