List:General Discussion« Previous MessageNext Message »
From:Daniel Kasak Date:March 9 2005 4:32am
Subject:Re: CASE statement and version 4.1.x
View as plain text  
Homam S.A. wrote:

>In the documentation, it doesn't mention which version
>of MySQL supports the CASE statement, but it refers to
>stored procedures, so is it only supported for 5.x?
>
>I can't get any example of a CASE statement work in
>MySQL.
>
>  
>
<snipped>

>For example, I can execute the following in MS SQL
>Server:
>
>UPDATE MyTable
>SET
>field1 = CASE WHEN field3 = 1 THEN 10 ELSE 20 END,
>field2 = field2 | CASE WHEN field4 = 'B' THEN 1 ELSE 0
>END | CASE WHEN field4 = 'C' THEN 2 ELSE 0 END
>  
>
Case works in 4.0.x ( and maybe before, haven't checked ).
Your problem is elsewhere.
I'm not sure if you can use the pipe symbol as an OR operator in the way 
you want - to be honest I haven't used it at all in SQL.
Try rewriting it to use nothing but case statements ( no | operators ).

-- 
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak@stripped
website: http://www.nusconsulting.com.au
Thread
CASE statement and version 4.1.xHomam S.A.9 Mar
  • Re: CASE statement and version 4.1.xDaniel Kasak9 Mar
    • Re: CASE statement and version 4.1.xPhilippe Poelvoorde9 Mar
  • RAID, MySQL and SATA - benchmarksRichard Dale9 Mar
RE: CASE statement and version 4.1.xTom Crimmins9 Mar
Re: RAID, MySQL and SATA - benchmarksGary Richardson9 Mar
RE: CASE statement and version 4.1.xHomam S.A.9 Mar
  • RE: CASE statement and version 4.1.xPaul DuBois9 Mar