MS Access SQL错误on子句
我试图在下面运行这个查询,但我一直得到一个错误。该查询在SQL Server中运行得非常好,但我不知道为什么会出现错误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
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