我有两个表,ksb,ksxx。本来是想把表直接改名成t1,t2,但报错提示找不到表,我就用了下面代码实现两表字段整合,非常感谢!
SELECT * FROM ksb INTO TABLE t1
SELECT * FROM ksxx INTO TABLE t2
AFIELDS(at1, "t1")
AFIELDS(at2, "t2")
lcStr = ""
FOR ln1 = 1 TO ALEN(at1, 1)
lcStr = lcStr + ",Aa." + at1[ln1, 1]
ENDFOR
lcStr= SUBSTR(lcStr, 2)
FOR ln1 = 1 TO ALEN(at2, 1)
IF NOT at2[ln1, 1] $ lcStr
lcStr = lcStr + ",Ab." + at2[ln1, 1]
ENDIF
ENDFOR
SELECT &lcStr FROM t1 aa, t2 ab WHERE aa.ksh=ab.ksh