sql select where id not exists in another table 1

sql select where id not exists in another table

where ID not in(select ID from T2 where HISTORY_FLG!=1)

Here is what the above code is Doing:
1. Select all the rows from T1 where the ID is not in T2.
2. Select all the rows from T2 where the ID is not in T1.
3. Select all the rows from T1 where the ID is not in T2 and the HISTORY_FLG is not 1.
4. Select all the rows from T2 where the ID is not in T1 and the HISTORY_FLG is not 1.

Similar Posts