有两张表,表A内的某些记录在表B中是不存在的(注:两个表的结构一模一样)。
我想用查询语句返回存在差异的记录,怎么返回的记录数是0呢?
我用了以下语句:AdodcUnite.RecordSource = "select * from A where not exists (select * from B)"请大虾指点,谢谢
我想用查询语句返回存在差异的记录,怎么返回的记录数是0呢?
我用了以下语句:AdodcUnite.RecordSource = "select * from A where not exists (select * from B)"请大虾指点,谢谢
假设id字段是唯一的 可以把他作为标识字段
select * from A where not exists (select 1 from B where a.id=b.id)
查询语句应该是这样写吧
AdodcUnite.RecordSource="select * from A where not exists (select * from B where A.field1=B.field1)"
field1为主键
"select * from A where field1 not in (select field1 from B)"
field1为主键
现更改下:B不是一个实际存在的表,而是一个查询语句返回的结果集。
即原来的语句为:"select * from A where not exists (select * from B where B.ChildCode<>''" 这样就不能用到
"select * from A where not exists (select * from B where A.field1=B.field1)" 因我原来的子查询上已有条件语句 where B.ChildCode<>''不知这种问题有没有办法解决?谢谢!
select * from A where not exists (select * from B where B.ChildCode <> '' and A.field1=B.field1)
多了个条件而已