I have two tables in a MySQL data base-
(agency table)
id
1
2
3
4
(banner table)
id agencyid
1 3
2 3
3 1
SELECT DISTINCT a.id FROM agency AS a, banner AS b WHERE a.id=b.agencyid;
Works great for extracting agencies with banners, but I also want to select all agencies that DO NOT have banners (and do it in SQL rather than in PHP).
SELECT a.id FROM agency AS a, banner AS b WHERE a.id!=b.agencyid;
Does not work, and I've tried various joins, all without success. Is this possible in SQL?