关键字“存在”附近的语法不正确

时间:2018-12-07 16:54:49

标签: sql-server subquery

我在子查询方面遇到问题,找不到语法错误的解决方案。目标是向所有展示黑色运动鞋的制造商展示价格超过70美元的标价。

我收到错误消息“ ERROR [42000] [Microsoft] [ODBC SQL Server驱动程序] [SQL Server]关键字'Exists'附近的语法不正确。”

Select ManufacturerName
From Manufacturer
Where Category Exists (Select Category, ListPrice, Color From Product Where 
Category = 'sneakers' And Color = 'Black' And ListPrice > 70);

谢谢

1 个答案:

答案 0 :(得分:2)

也许您需要这个:

select m.ManufacturerName
from Manufacturer m
where exists (select 1 
              from Product p
              where m.ManufacturerID = p.ManufacturerID and
                    p.Category = 'sneakers' and
                    p.Color = 'Black' And p.ListPrice > 70 
             );