Check a number of columns against multiple values
am 06.07.2006 09:42:12 von ben h
I want to check a number of 'columns' in a table to see if their value
equals either 4 or 5.
That is,
select Count(*) from myTable
WHERE step = 100 AND (
a=4 Or a=5 Or
b=4 Or b=5 Or
c=4 Or c=5 Or
d=4 Or d=5 Or
e=4 Or e=5 Or
f=4 Or f=5)
(there's more than this)
I thought there must be a better way of doing it!
Re: Check a number of columns against multiple values
am 06.07.2006 19:18:34 von Anthony Jones
"ben h" wrote in message
news:Opnt1%23MoGHA.4124@TK2MSFTNGP03.phx.gbl...
> I want to check a number of 'columns' in a table to see if their value
> equals either 4 or 5.
>
> That is,
> select Count(*) from myTable
> WHERE step = 100 AND (
> a=4 Or a=5 Or
> b=4 Or b=5 Or
> c=4 Or c=5 Or
> d=4 Or d=5 Or
> e=4 Or e=5 Or
> f=4 Or f=5)
>
> (there's more than this)
>
> I thought there must be a better way of doing it!
AND 4 IN (a,b,c,d,f) OR 5 IN (a,b,c,d,e,f)
Re: Check a number of columns against multiple values
am 07.07.2006 05:21:09 von ben h
> AND 4 IN (a,b,c,d,f) OR 5 IN (a,b,c,d,e,f)
>
Ah-hah, I did try that, but maybe I didn't do it right. Will try again.
Thanks.