Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.