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 |
|
venkath
Posting Yak Master
202 Posts |
Posted - 2006-10-05 : 10:19:13
|
| Hi alli need to update two columns in a table based on two conditionsUPDATE COMPANY_TYPESET COMP_PUB_ID_OPTION_CODE = 'REQ'WHERE ASK_FOR_PUB_ID ='-1'UPDATE COMPANY_TYPESET COMP_PUB_ID_OPTION_CODE = 'OPT'WHERE ASK_FOR_PUB_ID ='0'What i wanted to ask is..can i replace the above two update statements with single update statement Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-05 : 10:29:24
|
[code]UPDATE COMPANY_TYPESET COMP_PUB_ID_OPTION_CODE = case when ASK_FOR_PUB_ID = '-1' then 'REQ' when ASK_FOR_PUB_ID = '0' then 'OPT' end,WHERE ASK_FOR_PUB_ID in ('0', '-1')[/code] KH |
 |
|
|
venkath
Posting Yak Master
202 Posts |
Posted - 2006-10-05 : 11:00:42
|
| Thanks. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-05 : 11:16:26
|
or If it is for display, just use them in SelectSelect columns,case when ASK_FOR_PUB_ID = '-1' then 'REQ' when ASK_FOR_PUB_ID = '0' then 'OPT' else ASK_FOR_PUB_ID endfrom table MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|