609
社区成员
发帖
与我相关
我的任务
分享
如何从表A(总表)中找出表B(分表)中不存在的记录组合
假设表A和表B都只有两个字段id,name
如何用一句SQL返回表A中存在的id,name结果集而在表B中不存在的id,name结果集
select A.* from A left join B on A.id=B.id and A.name=B.name where B.id is null
select * from A where not exists(select top 1 * from B where A.ID=B.ID)
这两个都可以.
--前提:表中不能有text、ntext、image、cursor 数据类型的字段。
用CheckSum()最简单:
select * from A where checksum(*) not in (select checksum(*) from B)
----------------------------------------------------------------------
查询表A,表B中重复的记录
select * from A where checksum(*) in (select checksum(*) from B)
查询表A,表B中重复的记录,并把结果输入到表C中。
select * into c from A where checksum(*) in (select checksum(*) from B)
好象只能这么干?
for i = 1 to 150
if i = 1 or (i >= 4 and i <= 100) or ... --列为数值型的
if dw_1.getitemnumber(某行,i) = dw_2.getitemnumber(某行,i) then
...
else
...
end if
else
if i = 2 ...--列为字符串型的.
if dw_1.getitemstring(某行,i) = dw_2.getitemstring(某行,i) then
...
else
...
end if
else
...其他类型
end if
end if
any lany_a[], lany_b[]
int li_a, li_b
li_a = integer(sle_1.text) //用来临时输入需要比较的两行行号。
li_b = integer(sle_2.text)
lany_a = dw_1.object.data[li_a]
lany_b = dw_1.object.data[li_b]
if lany_a[3] = lany_b[3] then //本处只对比了一个元素,所有元素的对比自己写吧。
messagebox('', '相等')
else
messagebox('', '不相等')
end if