select多表导入有问题
请教select多表导入我有三个表
table1 table2 table3
col1 col3 col4 col5 col6
a a 5 a 6
b c 7 b 2
c d 9 d 3
d
想用select生成一表如下:
col1 col4 col6
a 5 6
b 0 2
c 7 0
d 9 3
CREATE CURSOR TABLE1 (COL1 C(1)) FOR I=1 TO 4 INSERT INTO TABLE1 VALUES (CHR(96+I)) ENDFOR CREATE CURSOR TABLE2 (COL3 C(1),COL4 N(1)) INSERT INTO TABLE2 VALUES ('a',5) INSERT INTO TABLE2 VALUES ('c',7) INSERT INTO TABLE2 VALUES ('d',9) CREATE CURSOR TABLE3 (COL5 C(1),COL6 N(1)) INSERT INTO TABLE3 VALUES ('a',6) INSERT INTO TABLE3 VALUES ('b',2) INSERT INTO TABLE3 VALUES ('d',3) SELECT TABLE1.COL1,IIF(ISNULL(TABLE2.COL4),0,TABLE2.COL4) AS COL4,IIF(ISNULL(TABLE3.COL6),0,TABLE3.COL6) AS COL6 FROM TABLE1 FULL JOIN TABLE2 ON TABLE2.COL3=TABLE1.COL1 FULL JOIN TABLE3 ON TABLE3.COL5=TABLE1.COL1 ORDER BY TABLE1.COL1 INTO CURSOR TABLE0 BROWSE