Select records from a table where two columns are not present in another table
Several ways to do this, here's one using not exists
:
select *from table1 t1where not exists ( select 1 from table2 t2 where t1.id = t2.id and t1.program = t2.program)
One possible variant is to use LEFT JOIN
:
SELECT Table1.*FROM Table1 LEFT JOIN Table2 ON Table1.ID = Table2.ID AND Table1.Program = Table2.ProgramWHERE Table2.ID IS NULL