Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kashif.special2005
Starting Member
10 Posts |
Posted - 2012-06-19 : 08:01:13
|
Hi,I want to update a Table1.class column with Table2 tables data with inner join with condition thatWhen age<=10 then 2 else 2, and I am using below query but it is giving me an error message that update Table1set class=case t.age <= 10 then 2 else 3endfrom Table1 v inner join Table2 t on v.id=t.idMsg 170, Level 15, State 1, Line 4Line 4: Incorrect syntax near '<'.Table 1id subject class100 B NULL100 E NULL100 R NULL101 R NULL101 K NULL101 A NULL102 Z NULL102 L NULL102 N NULL102 O NULLTable 2id age100 10101 15102 8Please help to resolve this problem.ThanksKashif |
|
matty
Posting Yak Master
161 Posts |
Posted - 2012-06-19 : 08:05:04
|
[code]update vset class= case WHEN t.age <= 10 then 2 else 3 endfrom Table1 v inner join Table2 t on v.id=t.id[/code] |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-06-19 : 08:06:07
|
CASEWHEN ... THENELSEEND No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|