You can nest the IF statement, putting another where 'soon' is like Jasper suggested. Or you can use the CASE WHEN THEN construct if you have a lot of conditions you need to check for.

On Oct 28, 2005, at 12:22 AM, Scott Haneda wrote:

on 10/27/05 6:34 PM, Scott Haneda at [EMAIL PROTECTED] wrote:


Right now, my update works as follows, and works fine, however, I want to do
a condition to say if products.ship_status = 1 then set
cart_test.shipping_status to 'now' else set it to 'soon'

UPDATE cart_test, products
SET cart_test.shipping_status = products.ship_status
WHERE products.id = cart_test.product_id AND cart_test.session_id = '5511'

Is this even possible, if so, can someone help me out a bit.
Thanks


I think I partly got it:
UPDATE cart, products
SET cart.ship_status = IF(products.ship_status = 1, 'now', 'soon')
WHERE products.id = cart.product_id AND
cart.session_id = "5511"

However, I need a ELSE in there, I can not always assume other than '1' is
'soon', is there some way to add in a ELSE?
--
-------------------------------------------------------------
Scott Haneda                                Tel: 415.898.2602
<http://www.newgeo.com>                     Novato, CA U.S.A.



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? [EMAIL PROTECTED]




--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to