我正在尝试以下查询从同一文件夹中的多个 dbf 文件中读取:
"SELECT COMPNO FROM REF10,REF11,REF12,REF08,REF09 WHERE SR_NO='RDDFT000108'";
以上产生以下错误:
“指定的字段 'COMPNO' 可以引用 SQL 语句的 FROM 子句中列出的多个表。”
如何在同一个查询中引用多个表?
尝试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';
您应该在查询文本中使用表定义:
"SELECT REF10.COMPNO, REF11.COMPNO, REF12.COMPNO, REF08.COMPNO, REF09.COMPNO FROM REF10,REF11,REF12,REF08,REF09 WHERE SR_NO='RDDFT000108'";