1. select a.* from TJ a where exists(select 1 from HIST b where a.part1=b.part1 and a.part2=b.part2 and a.part3=b.part3 ) 2. select a.* from TJ a where exists(select 1 from HIST b where a.part1=b.part1 and a.part2=b.part2 and a.part3<>b.part3 )3. select a.* from TJ a where not exists(select b.part2 from HIST b where a.part1=b.part1 )4. select a.* from HIST a where not exists(select b.part2 from TJ b where a.part1=b.part1 )
先谢了 是这样的,我要用VB编写一个程序,但需用到SQL,并用SQL实现对两个表指定字段的内容进行比较,类似如: select part1,part2,part3 from TJ where ... “比较函数或其他”...(select part1,part2,part3 where part1='aaa' and ...) 主要是比较字段对应的数据,按照上面不同的需求对select的结果count,以后做一个百分比统计。不知我描述的清不清楚,本人能力有限,还请各位高手多指教
select a.*
from TJ a
where exists(select 1 from HIST b where a.part1=b.part1 and a.part2=b.part2 and a.part3=b.part3 )
2.
select a.*
from TJ a
where exists(select 1 from HIST b where a.part1=b.part1 and a.part2=b.part2 and a.part3<>b.part3 )3.
select a.*
from TJ a
where not exists(select b.part2 from HIST b where a.part1=b.part1 )4.
select a.*
from HIST a
where not exists(select b.part2 from TJ b where a.part1=b.part1 )
是这样的,我要用VB编写一个程序,但需用到SQL,并用SQL实现对两个表指定字段的内容进行比较,类似如:
select part1,part2,part3 from TJ where ... “比较函数或其他”...(select part1,part2,part3 where part1='aaa' and ...)
主要是比较字段对应的数据,按照上面不同的需求对select的结果count,以后做一个百分比统计。不知我描述的清不清楚,本人能力有限,还请各位高手多指教
我已经测试过,exists的确不错,我用过minus 但感觉不太适合我的需求(也许我水平有限),呵呵!
非常感谢!结帖!