Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MS Access SQL错误on子句_Sql_Ms Access - Fatal编程技术网

MS Access SQL错误on子句

MS Access SQL错误on子句,sql,ms-access,Sql,Ms Access,我试图在下面运行这个查询,但我一直得到一个错误。该查询在SQL Server中运行得非常好,但我不知道为什么会出现错误 Select * FROM Products_Products Join (SELECT Products_Prices_ProductID, Max(IIf(Products_Prices_Code='ONEK',Products_Prices_Price,Null)) AS ONEK, Max(IIf(Products_Prices_Code='F

我试图在下面运行这个查询,但我一直得到一个错误。该查询在SQL Server中运行得非常好,但我不知道为什么会出现错误

Select *
FROM    Products_Products
Join
(SELECT Products_Prices_ProductID, 
    Max(IIf(Products_Prices_Code='ONEK',Products_Prices_Price,Null)) AS ONEK, 
    Max(IIf(Products_Prices_Code='FIVEK',Products_Prices_Price,Null)) AS FIVEK, 
    Max(IIf(Products_Prices_Code='TENK',Products_Prices_Price,Null)) AS TENK, 
    Max(IIf(Products_Prices_Code='TWENTYFIVEK',Products_Prices_Price,Null)) AS  TWENTYFIVEK,
    Max(IIf(Products_Prices_Code='Fifty',Products_Prices_Price,Null)) AS Fifty, 
    Max(IIf(Products_Prices_Code='OneHundred',Products_Prices_Price,Null)) AS OneHundred, 
    Max(IIf(Products_Prices_Code='FiveHundred',Products_Prices_Price,Null)) AS FiveHundred
FROM Products_Prices
GROUP BY Products_Prices_ProductID
) As pp
ON Products_Products_ID = pp_ProductID

谢谢。

我不确定,但试试这个

Select *
FROM    Products_Products
Join
(SELECT Products_Prices_ProductID AS pp_ProductID, 
    Max(IIf(Products_Prices_Code='ONEK',Products_Prices_Price,Null)) AS ONEK, 
    Max(IIf(Products_Prices_Code='FIVEK',Products_Prices_Price,Null)) AS FIVEK, 
    Max(IIf(Products_Prices_Code='TENK',Products_Prices_Price,Null)) AS TENK, 
    Max(IIf(Products_Prices_Code='TWENTYFIVEK',Products_Prices_Price,Null)) AS  TWENTYFIVEK,
    Max(IIf(Products_Prices_Code='Fifty',Products_Prices_Price,Null)) AS Fifty, 
    Max(IIf(Products_Prices_Code='OneHundred',Products_Prices_Price,Null)) AS OneHundred, 
    Max(IIf(Products_Prices_Code='FiveHundred',Products_Prices_Price,Null)) AS FiveHundred
FROM Products_Prices
GROUP BY Products_Prices_ProductID
) As pp
ON Products_Products_ID = pp_ProductID
刚刚在内部表的
Products\u Products\u ID
字段中添加了一个别名,名为
pp\u ProductID
。希望这能解决您的问题。

我所做的更改:

  • 连接
    更改为
    内部连接
  • 显式包含两个表中的所有字段
  • 将别名添加到表Products\u Products
  • 已修复要加入的字段的名称


完全错误是什么?提供您拥有的任何其他相关信息。FROM子句中存在语法错误。Access SQL不支持非限定的
Join
关键字。尝试使用
内部联接
。我不相信这是用SQL Server编写的。子查询中不包括您要加入的字段,
Products\u Products\u ID
pp\u ProductID
Select P.*, PP.*
FROM    Products_Products AS P
INNER JOIN
(SELECT Products_Prices_ProductID, 
    Max(IIf(Products_Prices_Code='ONEK',Products_Prices_Price,Null)) AS ONEK, 
    Max(IIf(Products_Prices_Code='FIVEK',Products_Prices_Price,Null)) AS FIVEK, 
    Max(IIf(Products_Prices_Code='TENK',Products_Prices_Price,Null)) AS TENK, 
    Max(IIf(Products_Prices_Code='TWENTYFIVEK',Products_Prices_Price,Null)) AS  TWENTYFIVEK,
    Max(IIf(Products_Prices_Code='Fifty',Products_Prices_Price,Null)) AS Fifty, 
    Max(IIf(Products_Prices_Code='OneHundred',Products_Prices_Price,Null)) AS OneHundred, 
    Max(IIf(Products_Prices_Code='FiveHundred',Products_Prices_Price,Null)) AS FiveHundred
FROM Products_Prices
GROUP BY Products_Prices_ProductID
) As pp
ON P.Products_Products_ID = pp.Products_Prices_ProductID