sql - Update multiple records with multiple conditions -


i trying update several records in sql table. data looks this

name record1_name record1_name_something record2_data_name record2_name_something 

the results need be

name record1 record2 record2_data 

here code have far

update table1 set column1 =  case 1 when '%record1%' 'record1' when '%record2%' , '%data%' 'record2_data' when '%record2%' , not '%data%' 'record2' 

the first when works no issue. second add and, though, fails. know syntax off on last 1 need try well.

i think looking this:

update table1 set column1 = case                   when column1 '%record1%' 'record1'                  when column1 '%record2%' , column1 '%data%' 'record2_data'                  when column1 '%record2%' , column1 not '%data%' 'record2'                  else 'record3'               end 

note: need specify value returned in case none of case boolean expressions satisfied. otherwise, case returns null.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -