假设有表A(id int,col1 int,col2 int,value int)
表B(col1 int,col2 int)现在要查询出表A中A.col1<>B.col1 or A.col2<>B.col2 的数据我的sql:
select * from A where id not in (select id from A,B where A.col1=B.col1 and A.col2=B.col2)有什么效率更高的写法吗?谢谢大家了PS:表中符合A.col1=B.col1 and A.col2=B.col2的数据比不符合的多很多
表B(col1 int,col2 int)现在要查询出表A中A.col1<>B.col1 or A.col2<>B.col2 的数据我的sql:
select * from A where id not in (select id from A,B where A.col1=B.col1 and A.col2=B.col2)有什么效率更高的写法吗?谢谢大家了PS:表中符合A.col1=B.col1 and A.col2=B.col2的数据比不符合的多很多
select * from A where id not in (select id from A,B where A.col1=B.col1 and A.col2=B.col2)好像有点问题,条件和sql语句!!!!
id1 id2 col1 col2 value
1 1 1 2 1
1 2 3 4 2
1 3 3 5 3
2 1 2 4 4
2 2 1 5 5B:
col1 col2
1 2
2 4则结果为
id1 id2 col1 col2 value
1 2 3 4 2
1 3 3 5 3
2 2 1 5 5