rgb192
asked on
Subquery returned more than 1 value
INSERT INTO information
SELECT
(SELECT productid from products where productid = 149880 ),
(select internalsku from products where productid IN (select productid from orderitems left join orders on orderitems.orderid = orders.orderid where orderitems.orderid > '7000149' )),
(SELECT orderid from orders where orderid = 7000149 )
select * from information
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
(20 row(s) affected)
SELECT
(SELECT productid from products where productid = 149880 ),
(select internalsku from products where productid IN (select productid from orderitems left join orders on orderitems.orderid = orders.orderid where orderitems.orderid > '7000149' )),
(SELECT orderid from orders where orderid = 7000149 )
select * from information
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
(20 row(s) affected)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can't run inserts in such a way....do your records (columns) relate to each other?
INSERT INTO information
SELECT p.productid ,p.internalsku , i.orderid
from products p
inner join orderitems i on p.productid = i.productid
inner join orders o on o.orderid = i.orderid
where i.orderid > '7000149' and p.productid = 149880
SELECT p.productid ,p.internalsku , i.orderid
from products p
inner join orderitems i on p.productid = i.productid
inner join orders o on o.orderid = i.orderid
where i.orderid > '7000149' and p.productid = 149880
ASKER
> =