stored-procedures - 存储过程;子查询返回超过 1 个值。当子查询跟随 =、!=、<、<=、>、>= 时,这是不允许的
问题描述
当我插入数据时,发生此错误子查询返回超过 1 个值,当子查询遵循 = 、 >=、>、<、<= 时,这是不允许的
INSERT INTO OrderItem
(
OrderItemGuid ,
OrderId ,
ProductId ,
Quantity ,
UnitPriceInclTax ,
UnitPriceExclTax ,
PriceInclTax ,
PriceExclTax ,
DiscountAmountInclTax ,
DiscountAmountExclTax ,
OriginalProductCost ,
AttributeDescription ,
AttributesXml ,
DownloadCount ,
IsDownloadActivated ,
LicenseDownloadId ,
ItemWeight ,
RentalStartDateUtc ,
RentalEndDateUtc ,
CreatedOnUtc ,
ProductName ,
ShortDescription ,
FullDescription ,
PictureId
)
VALUES
(
NULL ,
NULL ,
(SELECT ProductId FROM ShoppingCartItem WHERE CustomerId = @CustomerId ) ,
(SELECT Quantity FROM ShoppingCartItem WHERE CustomerId = @CustomerId) ,
(SELECT SUM(P.Price*SC.Quantity) AS UnitPriceInclTax FROM ShoppingCartItem SC INNER JOIN Product P ON SC.Id = P.Id WHERE SC.CustomerId = @CustomerId AND SC.ProductId = @ProductId ) ,
(SELECT (P.Price) AS UnitPriceExclTax FROM ShoppingCartItem SC INNER JOIN Product P ON SC.Id = P.Id WHERE SC.CustomerId = @CustomerId AND SC.ProductId = @ProductId) ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL ,
@CreatedOnUtc ,
(SELECT (P.Name) AS ProductName FROM ShoppingCartItem SC INNER JOIN Product P ON SC.Id = P.Id WHERE SC.CustomerId = @CustomerId AND SC.ProductId = @ProductId) ,
(SELECT (P.ShortDescription) AS ShortDescription FROM ShoppingCartItem SC INNER JOIN Product P ON SC.Id = P.Id WHERE SC.CustomerId = @CustomerId AND SC.ProductId = @ProductId) ,
(SELECT (P.FullDescription) AS FullDescription FROM ShoppingCartItem SC INNER JOIN Product P ON SC.Id = P.Id WHERE SC.CustomerId = @CustomerId AND SC.ProductId = @ProductId) ,
(SELECT (PM.PictureId) AS PictureId FROM ShoppingCartItem SC INNER JOIN Product_Picture_Mapping PM ON SC.Id = PM.Id WHERE SC.CustomerId = @CustomerId AND SC.ProductId = @ProductId)
)
我收到以下错误:
子查询返回超过 1 个值。当子查询跟随 =、!=、<、<=、>、>= 或子查询用作表达式时,这是不允许的。
有任何想法吗?
解决方案
推荐阅读
- jquery - 在下拉值更改时加载的部分视图上更新引导验证
- python - 如何在python中根据关键字提取txt文件的一部分?
- javascript - 在 react-select 中访问内部输入元素
- android - Android LiveData:如何避免从后台重新打开应用程序时从数据库传输数据?
- python - 将python双端队列分配给列表
- node.js - 如何查询多个 MongoDB 集合和 NodeJS?
- node.js - elasticsearch 检查索引是否存在在第一次运行时返回 true
- javascript - 如何动态解构一个巨大的 JSON 对象?
- django - 设计一个 django 模型,以便我们可以有一个类别字段,并且该类别可以有未知的属性
- reactjs - 父组件中的子组件多次在 React + Redux 中不起作用