1

我正在尝试以下查询从同一文件夹中的多个 dbf 文件中读取:

"SELECT COMPNO FROM REF10,REF11,REF12,REF08,REF09 WHERE SR_NO='RDDFT000108'";

以上产生以下错误:

“指定的字段 'COMPNO' 可以引用 SQL 语句的 FROM 子句中列出的多个表。”

如何在同一个查询中引用多个表?

4

2 回答 2

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';
于 2013-11-01T04:39:36.390 回答
0

您应该在查询文本中使用表定义:

"SELECT REF10.COMPNO, REF11.COMPNO, REF12.COMPNO, REF08.COMPNO, REF09.COMPNO FROM REF10,REF11,REF12,REF08,REF09 WHERE SR_NO='RDDFT000108'";
于 2013-11-01T05:08:46.630 回答