What's wrong with this simple query using NOT IN?
postgresql, sql
Solution
Try this, you have a null value and null is not equal to anything not even another null
select *
from radio_bin
where id not in (select radio_bin from radio where radio_bin is not null)
See also NOT IN and NULLS which shows you how to use either LEFT JOIN or NOT EXISTS
Problem
Schema: ``` radio_bin.id radio.id radio.radio_bin -> radio_bin.id ``` Queries: ``` select * from radio_bin ``` 72 rows. ``` select * from radio_bin where id in (select radio_bin from radio) ``` 50 rows. (And FWIW:) ``` select distinct radio_bin from radio ``` 51 rows, including a null. That's all good. Now: ``` select * from radio_bin where id not in (select radio_bin from radio) ``` 0 rows. Why? Shouldn't I get the 22 radio_bin.id numbers that don't have a radio pointing to them?