2015-11-04 92 views
0

我有以下的sql返回我需要正确的记录。Microsoft Access 2010追加查询错误

INSERT INTO Historic 
SELECT * FROM current 
    LEFT JOIN Historic ON (current.aptdat = Historic.aptdat) 
    AND (current.ordnum = Historic.ordnum) 
    AND (current.type = Historic.type) 
    AND (current.itmcod = Historic.itmcod) 
WHERE (Historic.aptdat & Historic.ordnum & Historic.type) Is Null 
AND current.ordnum is not null; 

问题是,当我尝试运行它作为追加查询,我得到的错误**

重复输出目的地 'APTDAT'

**

我错过了什么?

PS:代码的最后一行是确保“当前”表中的记录(链接的Excel表单)在它们只包含空白行时不会返回。不包括该行意味着返回800行,但只有3行包含数据!

欢呼

回答

1

SELECT *给所有表的所有列在FROM子句。因此,您也可以获得Historic的所有列,并且因为这也有一个列aptdat,您会收到错误消息。

解决方案:使用<table>.*

INSERT INTO Historic 
SELECT current.* FROM current 
    LEFT JOIN Historic ON ... 
+0

您好,感谢您的答复!有效 :) – Nick