从多个链接的Excel文件中查询

时间:2015-08-19 18:35:35

标签: sql database ms-access

我目前已将多个Excel文件链接到Access(每个月一个文件),我想从每个文件创建一个查询,它将为我提供“主查询”。所有文件与标题和格式完全相同。我无法合并所有三个然后链接,因为它远远超过Excel最大值。

我试过了,它给了我错误Data type mismatch in criteria expression

  SELECT [Created Date], [Store Name], ProductID, [Customer First Name] & " " & [Customer Last Name] AS CustomerName
  FROM August2015
  WHERE ProductID = 1587996 OR ProductID = 1587985 
  UNION
  SELECT [Created Date], [Store Name], ProductID, [Customer First Name] & " " & [Customer Last Name] AS CustomerName
  FROM July2015
  WHERE ProductID = 1587996 OR ProductID = 1587985 
  UNION
  SELECT [Created Date], [Store Name], ProductID, [Customer First Name] & " " & [Customer Last Name] AS CustomerName
  FROM June2015
  WHERE ProductID = 1587996 OR ProductID= 1587985 

有人能指出我正确的方向吗?感谢。

1 个答案:

答案 0 :(得分:2)

听起来像ProductID是一个字符串。如果是这样的话:

WHERE ProductID = '1587996' OR ProductID = '1587985'