当我插入数据时,发生此错误的子查询返回多个值,当子查询遵循=,> =,>,<,<=
时,不允许这样做
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)
)
我收到以下错误:
子查询返回了多个值。当子查询遵循=,!=,<,<=,>,> =或将子查询用作表达式时,不允许这样做。
有什么想法吗?