shogemuk Posted August 22, 2011 Share Posted August 22, 2011 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 More sharing options...
AyKay47 Posted August 22, 2011 Share Posted August 22, 2011 remove the parenthesis from this line WHERE (x_payments.PaymentComplete = 1) AND (x_orders.OrderStatus = 0)) around your WHERE conditionals Link to comment https://forums.phpfreaks.com/topic/245415-operand-should-contain-1-columns-error/#findComment-1260448 Share on other sites More sharing options...
Muddy_Funster Posted August 22, 2011 Share Posted August 22, 2011 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. Link to comment https://forums.phpfreaks.com/topic/245415-operand-should-contain-1-columns-error/#findComment-1260450 Share on other sites More sharing options...
shogemuk Posted August 22, 2011 Author Share Posted August 22, 2011 Thanks a lot for the help guys. much appreciated Link to comment https://forums.phpfreaks.com/topic/245415-operand-should-contain-1-columns-error/#findComment-1260548 Share on other sites More sharing options...
The Little Guy Posted August 22, 2011 Share Posted August 22, 2011 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 ) ); Link to comment https://forums.phpfreaks.com/topic/245415-operand-should-contain-1-columns-error/#findComment-1260551 Share on other sites More sharing options...
Muddy_Funster Posted August 22, 2011 Share Posted August 22, 2011 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? Link to comment https://forums.phpfreaks.com/topic/245415-operand-should-contain-1-columns-error/#findComment-1260556 Share on other sites More sharing options...
fenway Posted August 22, 2011 Share Posted August 22, 2011 Clearly not. Link to comment https://forums.phpfreaks.com/topic/245415-operand-should-contain-1-columns-error/#findComment-1260585 Share on other sites More sharing options...
The Little Guy Posted August 22, 2011 Share Posted August 22, 2011 of course I did... just not all of it Link to comment https://forums.phpfreaks.com/topic/245415-operand-should-contain-1-columns-error/#findComment-1260604 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.