This should be obvious to me, but my brain appears to be fried.
I have a two tables. Table2 is joined to table1 by table1's id. There are potentially multiple records for table2 for each record in table1. I want to get all the records from table1 where none of the associated records in table2 contain a certain value.
table1
id
table2
id
table1id
col1
So I can get the full set of data by joining thusly:
select table1.id, table2.col1 from table1 inner join table2 on table2.table1id = table1.id
results in:
table1.id table2.col1
---------------------------
1 9
1 1
1 8
2 4
2 3
I only want to get records from table1 if NONE of the records in table2 are in a certain list. I tried doing "where table2.col1 NOT IN (9,8,7)" as the main where clause, and within the inner join. All it does is filter out that combo. EG:
table1.id table2.col1
---------------------------
1 1
2 4
2 3
What I really want to do is not get record "1" from table1 at all.
Thanks!