现在有表A与表B:
表A
Id User Value
1 aa 3
2 bb 6
3 cc 2
4 dd 3
5 ee 1
表B
UId Value
1 3
2 5
3 2
1 7
5 4
要获取表A的的数据,条件A.Id <> B.UId And A.Value <> B.Value(同一记录),这样的查询怎样写效率高?
------解决方案--------------------
- SQL code
--05select id,value from aexceptselect uid,value from b-----orselect *from a twhere not exists (select 1 from b where uid = t.id or value = t.value)
------解决方案--------------------
- SQL code
select A.* from Ainner join B on A.Id<>B.UId and A.Value <> B.Value
------解决方案--------------------
- SQL code
select *from awhere not exists (select 1 from b where uid = a.id or value = a.value)
------解决方案--------------------
select * from A where not exists(
A.ID=B.UID and A.value=B.value)