A表
key1 key2
1000 00
1000 01
2000 00
2000 01B表
key1 key2
1000 00
1000 01
1000 99
2000 00
2000 01
2000 99注:key1和key2为两表的主键如何写一句SQL语句,能够将B表的
key1 key2
1000 99
2000 99
两条数据插入到A表中去?功能就是如果A表中相同主键的数据不存在,就将B表中的这条数据插入A表非常谢谢
key1 key2
1000 00
1000 01
2000 00
2000 01B表
key1 key2
1000 00
1000 01
1000 99
2000 00
2000 01
2000 99注:key1和key2为两表的主键如何写一句SQL语句,能够将B表的
key1 key2
1000 99
2000 99
两条数据插入到A表中去?功能就是如果A表中相同主键的数据不存在,就将B表中的这条数据插入A表非常谢谢
where (b.key1,key2) not in
(select b.key1,b.key2 from a,b where a.key1=b.key1 and a.key2=b.key2)
select B.*
from B left join A on B.key1=A.key1 and B.key2=A.key2
where A.key1 is null;