Jump to content

MYSQL - How to use UPDATE with IF-ELSE condition


rahulephp

Recommended Posts

I have three columns -  id, programname, status

 

I wanted to use UPDATE with IF condition something like this:

 

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.