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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Correlated Subquery

Status
Not open for further replies.

toddOne

Programmer
Jul 20, 2001
41
US
Hello All Sybase SQL Guru's,

I need some assistance with a correlated subquery. Right now I have a select statement within a stored procedure that has the tables joined with an outer join and few conditions in the where clause. I need to add more conditions to the where clause and the only way I have been able to get close to producing the results is by removing the outer joins and using union all on slightly modified select statements with just different where conditions.
Below is an example of what I have and then below that is what I need. Please Advise!! Thanks in advance for your time and efforts!

NOW:

select a.field1
,a.field2
,b.field1
,c.field1
from tab1 a, tab2 b, tab3 c
where b.fieldX =* a.fieldY + a.fieldZ
and c.fieldA =* a.fieldB + a.fieldC
and b.whatever is null
and c.whatever is null

NEEDED:

select a.field1
,a.field2
,(select b.field1 from tab2 b where...)
,(select c.field1 from tab3 c where...)
from tab1 a
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top