-
Hi
I have simple doubt in sql statement .
I have column from a table where column name = ANO AND ITS VALUE IS 5 ( ANO = 5) and i need to match this
column with other five columns in other table ( AN1,AN2AN3,AN4,AN5) and all these columns should have the same value
it should be like this
select count(*)
from temp
where ano=an1
ano=an2
ano=an3
ano=an4
ano=an5
Is there any alternate way where we can match One column value with all the other five coulmns
Thanks
lnr
-
select count(*)
from temp
where ano in (an1,an2,an3,an4,an5)
Eugene
OCP
San Diego
-
I think there's nothing wrong with this:
Code:
select count(*)
from temp
where ano=an1
AND ano=an2
AND ano=an3
AND ano=an4
AND ano=an5
eugene:
Code:
select count(*)
from temp
where ano in (an1,an2,an3,an4,an5)
does not work. We can rewrite the IN() clause as "ano=an1 OR ano=an2 OR ano=an3 ... "
so the condition is true if AT LEAST ONE an? is equal to ano. But lnreddy needs to have ALL an? equal to ano.
Ales The whole difference between a little boy and an adult man is the price of toys
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|