Page 1 of 1

Would this SQL line work?

Posted: Fri Jan 11, 2019 5:57 pm
by IT-Me-Up.co.uk
Hi there,

I have imported some products with some incorrect stock status, would this SQL work?

UPDATE `itmeup_product`
SET stock_status_id = CASE
WHEN quantity=0 THEN 5*stock_status_id
ELSE stock_status_if
END

If Quantity is = then set Stock Status 5 = (Out of Stock)
Currently its is showing as 6 (2-3 Days)

Re: Would this SQL line work?

Posted: Fri Jan 11, 2019 7:06 pm
by xxvirusxx
Why dont' use something like this?

Code: Select all

UPDATE `itmeup_product` SET stock_status_id = X  WHERE quantity = 0;
or

Code: Select all

UPDATE `itmeup_product` SET stock_status_id = X  WHERE quantity = 0 AND something_else = Y;
etc...

Is weird to ask for 20 years experience in IT :)