Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re:the 'OR" condition in sql

Status
Not open for further replies.

raji96

Programmer
Aug 7, 2001
64
US
Hi,

I have an sql like this

select distinct b.field3
from
table1 a,
table2 b,
table3 c,
table4 d
where
c.field5="something" and
c.feild2=b.field2 and
(((b.field2=a.field2) and (b.field3=a.field3)) or
((b.field2=c.field2) and (b.field3=c.field3)))


when this is executed ((b.field2=a.field2) and (b.field3=a.field3)) is basically has no rows in the table hence the condition is something like null or somerows.

But even though the second condition((b.field2=c.field2) and (b.field3=c.field3)) is true
the end result is always 'no rows return'.why is it?

since the second condition is true and has rows and the first one is false and since i am using or shouldn't it return the rows.
 
I get rows returned when I do a similar query on my database. Maybe the extra condition, c.field5="something", is causing your result to be null.

By the way, I suppose your query is a simplification, but it's not clear why you include table4 in your sql. It's never referenced.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top