Jump to content

Operand should contain 1 column(s) Error


shogemuk

Recommended Posts

Hi Guys,

I am trying to run the following script but I keep getting the following error Operand should contain 1 column(s)

 

UPDATE  x_orders

SET OrderStatus = 1

WHERE OrderID IN

(

SELECT    *

FROM        x_orders INNER JOIN

                      x_payments ON x_orders.OrderID = x_payments.OrderID

WHERE    (x_payments.PaymentComplete = 1) AND (x_orders.OrderStatus = 0))

 

 

Does anyone have any idea!

Thanks in advanced!!

Link to comment
https://forums.phpfreaks.com/topic/245415-operand-should-contain-1-columns-error/
Share on other sites

remove the parenthesis from this line

 

WHERE     (x_payments.PaymentComplete = 1) AND (x_orders.OrderStatus = 0))

 

around your WHERE conditionals

Why?

 

The problem is that the subquery is returning multiple fields, IN requires that a single field dataset is returned.  Don't use Select * in the subquery, only select the fild that you need for the comparison.

Try this, it looks like you are missing a pair of parenthesis, and a limit

 

I am not sure if you can have a sub select inside of an in, but if you can I would assume it would look like this.

 

UPDATE  x_orders
SET OrderStatus = 1
WHERE OrderID IN(
(
	SELECT     *
	FROM         x_orders INNER JOIN
	x_payments ON x_orders.OrderID = x_payments.OrderID
	WHERE (x_payments.PaymentComplete = 1) AND (x_orders.OrderStatus = 0) limit 1
)
);

Try this, it looks like you are missing a pair of parenthesis, and a limit

 

I am not sure if you can have a sub select inside of an in, but if you can I would assume it would look like this.

 

UPDATE  x_orders
SET OrderStatus = 1
WHERE OrderID IN(
(
	SELECT     *
	FROM         x_orders INNER JOIN
	x_payments ON x_orders.OrderID = x_payments.OrderID
	WHERE (x_payments.PaymentComplete = 1) AND (x_orders.OrderStatus = 0) limit 1
)
);

 

you didn't even read my post, did you?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.