table 1
id value
1 111
1 222
1 444
3 333
3 444table 2
id value
1 222
1 444
2 111
3 444得到
table 2
id value
1 111
3 333
就是找到按照每个ID,Value值在表1中有而在表2种没有的门所有记录
id value
1 111
1 222
1 444
3 333
3 444table 2
id value
1 222
1 444
2 111
3 444得到
table 2
id value
1 111
3 333
就是找到按照每个ID,Value值在表1中有而在表2种没有的门所有记录
where not exists(select * from table2 where id=a.id and value=a.value)
where not exists(select 1 from table2 where id=a.id and value=a.value)
where value not in (select value from table2 where table1.id = table2.id)
table 1
AA id value
1 1 111
1 1 222
1 1 444
1 3 333
1 3 444
2 1 222
2 1 444
2 2 111
2 3 444
得到
table 2
AA id value
1 1 111
1 3 333
就是找到按照每个ID,Value值在表1中有而在表2种没有的门所有记录