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 |
|
t1g312
Posting Yak Master
148 Posts |
Posted - 2005-02-20 : 02:50:13
|
| Hi all,I need to use a where condition based on the value of a particular field.E.g.:select a,b,c from table where case a = 'something' then b = 'efg' else c = 'xyz' endI know the above query is wrong, but I hope you get what I'm trying to acheive. How do I go about it?Thanks in advance,Adi-------------------------/me sux @sql server |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-02-20 : 07:43:56
|
| [code]select aaaaa,bbbbb,cccccfrom table WHERE (aaaaa = 'something' AND bbbbb = 'efg') OR ( (aaaaa <> 'something' OR aaaaa IS NULL) AND ccccc = 'xyz' )[/code] |
 |
|
|
t1g312
Posting Yak Master
148 Posts |
Posted - 2005-02-20 : 08:13:02
|
quote: Originally posted by Kristen
select aaaaa,bbbbb,cccccfrom table WHERE (aaaaa = 'something' AND bbbbb = 'efg') OR ( (aaaaa <> 'something' OR aaaaa IS NULL) AND ccccc = 'xyz' )
Super!!! Thanks Kristen!Adi-------------------------/me sux @sql server |
 |
|
|
|
|
|