case - SQL Update - Multiple Rows and Multiple Critieria in one SQL Statement -


i trying update 2 fields based on 2 different criteria , cannot figure out how accomplish in single sql statement.

is possible without loop?

here single-row examples of trying accomplish:

update leadtimes set leadtime = 10 supplier = 123 , location = 1; update leadtimes set transit_leadtime = 5 supplier = 123 , location = 1; update leadtimes set leadtime = 12 supplier = 123 , location = 2; update leadtimes set transit_leadtime = 6 supplier = 123 , location = 2; update leadtimes set leadtime = 5 supplier = 223 , location = 1; update leadtimes set transit_leadtime = 3 supplier = 223 , location = 1; update leadtimes set leadtime = 7 supplier = 223 , location = 2; update leadtimes set transit_leadtime = 2 supplier = 223 , location = 2; 

this statement found online haven't been successful in modifying job.

update categories     set display_order = case id         when 1 3         when 2 4         when 3 5     end,     title = case id         when 1 'new title 1'         when 2 'new title 2'         when 3 'new title 3'     end id in (1,2,3)  

update leadtimes      set          leadtime = case cast(supplier varchar(max)) + cast(location varchar(max))             when '1231' 10             when '1232' 12             when '2231' 5             when '2232' 7         end,         transit_leadtime = case cast(supplier varchar(max)) + cast(location varchar(max))             when '1231' 5             when '1232' 6             when '2231' 3             when '2232' 2         end  supplier in (123, 223) , location in (1, 2); 

here results:

enter image description here


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -