I'm trying to make an efficient query which compares two tables and finds rows which are not in common. The tables are phones and callrecords. I want to see which phones have no entries in the callrecords (not been used in a while).
What I came up with works but isn't very efficient I feel
select * from phones p
where p.name not in (select cr.name from callrecord cr)
I thought perhaps doing a left join and then distinct might help. I don't want the actual callrecords in the result, just the list of phones. Any help is appreciated.
p.s. if I get this working, I was thinking to expand the query to include phones which have old records (calltime < say 30 days). Not sure if that might change the approach.