i have two tables. First table column value is 1,2,7
. Second table column value is 1,2,3,4,5,6,7,8,9,10
.
what i needed is i want to fetch second table values except first table values.Result should be 3,4,5,6,8,9,10
.I do no what is the query for this one.Please help me.
SELECT value FROM secondtable WHERE value NOT IN (SELECT value FROM firsttable)
The standard SQL is to use NOT IN
or NOT EXISTS
:
select t2.*
from t2
where not exists (select 1 from table1 t1 where t1.value = t2.value);