MySQL Forums
Forum List  »  Newbie

Re: converting multiple update queries into case statement
Posted by: thellie root
Date: August 17, 2010 08:57PM

ok, after changing the field option to NULL - this is what i've queried:

UPDATE smf_members_backup SET id_group = CASE
WHEN (CURDATE() < startdate)
THEN id_group = '24'
WHEN (CURDATE() BETWEEN startdate AND enddate)
THEN id_group = '23'
WHEN (CURDATE() > enddate)
THEN id_group = '20'
ELSE id_group
END

but it booleans it - every affected record is now 1 or 0... i don't need to know whether it's true or false, i need the data changed to either '20', '23' or '24'... is a CASE statement the wrong thing to use for this?

sorry if it seems a stupid question to you :p

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.