On Thu, 2005-10-27 at 21:22 -0700, Scott Haneda wrote:
> 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?
Depends how many alternate branches you want. You could just nest
another IF where 'soon' is.
--
Jasper Bryant-Greene
General Manager
Album Limited
e: jasper@stripped
w: http://www.album.co.nz/
b: http://jbg.name/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand