|
-
Apr 7th, 2009, 02:49 AM
#1
Thread Starter
PowerPoster
Multiple if-else conditions in MySQL
Hi All,
I want to use multiple if-else conditions on the following query.
Code:
UPDATE tblTimeZone
SET GMTZoneName = '(GMT+' + CAST(ZoneValue AS varchar(5)) + ') ' + ZoneName
WHERE ZoneValue > 0
UPDATE tblTimeZone
SET GMTZoneName = '(GMT' + CAST(ZoneValue AS varchar(5)) + ') ' + ZoneName
WHERE ZoneValue < 0
UPDATE tblTimeZone
SET GMTZoneName = '(GMT) ' + ZoneName
WHERE ZoneValue = 0
UPDATE tblTimeZone
SET GMTZoneName = 'Select TimeZone'
WHERE ZoneValue = 100
Can someone help to convert this into if-else statement.
I tried to use case statement as follows, but messit
Code:
SELECT CASE
WHEN ZoneValue > 0
THEN
SET GMTZoneName = '(GMT+' + CAST(ZoneValue AS varchar(5)) + ') ' + ZoneName
ELSE 'Negative'
END GMTZoneName
FROM tblTimeZone
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|