Microsoft Access 2010附加查询错误

时间:2015-11-04 14:15:31

标签: sql performance ms-access append

我有以下sql,它返回我正确需要的记录。

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:代码的最后一行是为了确保来自'当前'的记录。 table,它是一个链接的Excel工作表,如果它们只包含空行,则不会返回。不包括该行意味着返回800行,但只有3行包含数据!

欢呼声

1 个答案:

答案 0 :(得分:1)

SELECT *给出FROM子句中所有表的所有列。因此,您也会获得Historic的所有列,并且由于此列也有aptdat列,因此您会收到错误。

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

INSERT INTO Historic 
SELECT current.* FROM current 
  LEFT JOIN Historic ON ...
相关问题