From: Date: October 28 2005 6:22am Subject: Re: Possible to use a conditional in this UPDATE List-Archive: http://lists.mysql.com/mysql/190970 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit on 10/27/05 6:34 PM, Scott Haneda at lists@stripped 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 Novato, CA U.S.A.