Quick Search

Update Table value with case in Sql

February 27th, 2010 by admin
Leave a reply »

 

Use case for update the table value using sql query
Ex. table Gender_tbl and like this
id Gen_Name
1 Male
2 Male
3 Female
4 Femal
5 Male
no I have to update Gen_Name Male with M and Femal with F
solution:
UPDATE GENDER_TBL SET Gen_Name= (CASE WHEN (Gen_Name=’Male’) THEN ‘M’ WHEN (Gen_Name=’Female’) THEN ‘F’ else ‘ ‘ end)

Posted in Database

You can follow any responses to this entry through the RSS 2.0 Feed. You can leave a response , or trackback from your own site.

Leave a Reply