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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Very Complex SQL Query (for me).. please help

Author  Topic 

cheyenne
Starting Member

3 Posts

Posted - 2011-02-13 : 22:54:18
select p.problem_name, pd.problem_description from problems p, problem_details pd ON
p.p_id = pd.p_id WHERE
p.mixed_t1 in (select value from symptoms where brightness = 'dark') and
p.mixed_t2 in (select value from symptoms where brightness = 'bright') and
p.mixed_flair in (select value from symptoms where brightness = 'bright') and
p.mixed_gre in (select value from symptoms where brightness = 'bright') and
p.mixed_diffusion in (select value from symptoms where brightness = 'bright') and
p.mixed_adc in (select value from symptoms where brightness = 'bright') and
p.fat_sat_post_t1 in (select value from symptoms where brightness = 'rim')


Can anyone tell me why it doesn't work?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-02-13 : 22:56:46
because you have 2 WHERE in the query ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

cheyenne
Starting Member

3 Posts

Posted - 2011-02-13 : 22:59:38
Sorry that was a typo but the issue is that I'm getting 0 results back

I have defined a p_id = 0 on both tables and added some data for the pd.problem_description
and p_id is defined in the problem table
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-13 : 23:50:30
in order to find the issue .. execute your statement with out any condition (without where clause)

if rows are not returned Then

Execute the query only with first "where" condition

if rows are not returned Then

Execute the query only with first and second "where" condition

if rows are not returned Then
..
..
..
Till end.

You will find the problem as if the issue is due to the Join And / OR due to one of the conditions in your where clause.

Cheers
MIK
Go to Top of Page

cheyenne
Starting Member

3 Posts

Posted - 2011-02-14 : 08:24:12
thanks. i was able to find the error.
Go to Top of Page

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 2011-02-14 : 22:55:56
quote:
Originally posted by cheyenne

thanks. i was able to find the error.



So what was the error?


--Jeff Moden
Go to Top of Page
   

- Advertisement -