Posted:
Thu Nov 25, 2010 6:55 am (14 years, 1 month ago)
I have three columns - id, programname, status
I wanted to use UPDATE with IF condition something like this:
Code:
UPDATE elec_products
IF(programname ='Argos')
(
SET status = 1
)
ELSEIF(programname ='sify')
(
SET status = 2
)
ELSE
(
SET status = 3
)
ENDIF
WHERE programname IS NOT NULL
I am not sure if it'll be possible. Please suggest the best possible ways to do this.
Thank you
gmybft Junior WebHelper
Joined: 30 Nov 2010
Posts: 1
Posted:
Tue Nov 30, 2010 2:16 am (14 years ago)
Try following.
Code:
UPDATE elec_products
SET STATUS = CASE
WHEN programname = 'Argos' THEN
1
WHEN programname = 'sify' THEN
2
ELSE
3
END
WHERE programname IS NOT NULL;
You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot edit your posts in this forum. You cannot delete your posts in this forum. You cannot vote in polls in this forum.