I have a city table like:
state city
----- ----
texas houston
texas austin
texas dallas
texas san antonio
texas beaumont
texas brownsville
texas el paso
california anaheim
california san diego
california los angeles
california oakland
california simi valley
california san francisco
I need a query to find states that don’t have a city named Houston or Dallas. My first thought was this
select distinct state from cities where city not in ('houston', 'dallas');
but that will not work. I think I need a subquery and NOT IN of some kind.
source
share