** 把你2个人输入的表名称,替换下面的 表1,表2,如果是有路径的,就替换为带路径的,如: c:\xxxx\yyy.dbf
select t1.zkzh,t1.xm,t1.yw,t1.sx,t1.yy,t2.yw as yw2,t2.sx as sx2,t2.yy as yy2 ; from 表1 as t1,表2 as t2; where t1.zkzh=t2.zkzh and t1.xm=t2.xm and (t1.yw<>t2.yw or t1.sx<> t2.sx or t1.yy<>t2.yy)
** 把你2个人输入的表名称,替换下面的 表1,表2,如果是有路径的,就替换为带路径的,如: c:\xxxx\yyy.dbf
select t1.zkzh,t1.xm,t1.yw,t1.sx,t1.yy,t2.yw as yw2,t2.sx as sx2,t2.yy as yy2 ; from 表1 as t1,表2 as t2; where t1.zkzh=t2.zkzh and t1.xm=t2.xm and (t1.yw<>t2.yw or t1.sx<> t2.sx or t1.yy<>t2.yy)
local km[3]
km[1]="yw"
km[2]="sx"
km[3]="yy"
lcSql=""
For lnCnt=1 To Alen(km,1) lcSql=lcSql+IIF(lnCnt=1,""," UNION ALL ")+"SELECT a1.zkzh,a1.xm,'"+km[lnCnt]+"' AS km,a1."+km[lnCnt]+" AS cj,a2."+km[lnCnt]+" AS cj1 FROM cj a1,cj1 a2 WHERE a1.zkzh=a2.zkzh AND a1."+km[lnCnt]+"!=a2."+km[lnCnt]
EndFor
MessageBox(lcSql,0,"SQL 代码")
&lcSql
Use In cj
Use In cj1