
敲代码查询的时候出了这个错误,求解
子查询返回的值不止一个,当子查询跟在等于,叹号,还有各种符号时,这种情况是错误的
子查询返回了多个值 ,确保只有一个返回值。如果有多个 可以使用in
- 你可以尝试这种写法是否可以
Select ProductID, productname, Unitprice
from products t where exists
( select 1 from products t1
where t1. Product Name='Aniseed Syrup' and t.CategroyID= t1.CategroyID
and t. Unitprice> t1.Unitprice*2
) - 如果还是报错,把t.CategroID =t1.CategroID 改成 t表的这个ID在 t1表中。
子句中order by 取top 1