我正在尝试以下查询来读取同一文件夹中的多个dbf文件:
"SELECT COMPNO FROM REF10,REF11,REF12,REF08,REF09 WHERE SR_NO='RDDFT000108'";
以上会产生以下错误:
“指定字段'COMPNO'可以引用多个表 列在SQL语句的FROM子句中。“
如何在同一查询中引用多个表?
答案 0 :(得分:1)
尝试使用UNION
SELECT COMPNO FROM REF10 WHERE SR_NO='RDDFT000108';
UNION ALL;
SELECT COMPNO FROM REF11 WHERE SR_NO='RDDFT000108';
UNION;
SELECT COMPNO FROM REF12 WHERE SR_NO='RDDFT000108';
UNION;
SELECT COMPNO FROM REF08 WHERE SR_NO='RDDFT000108';
UNION;
SELECT COMPNO FROM REF09 WHERE SR_NO='RDDFT000108';
答案 1 :(得分:0)
您应该在查询文本中使用表定义:
"SELECT REF10.COMPNO, REF11.COMPNO, REF12.COMPNO, REF08.COMPNO, REF09.COMPNO FROM REF10,REF11,REF12,REF08,REF09 WHERE SR_NO='RDDFT000108'";