Link to home
Start Free TrialLog in
Avatar of dneill8
dneill8Flag for United States of America

asked on

How to use two select elements as if they were two scalars returned from subquery

The below doesn't work as a subquery because I'm trying to use the two select elements as if they were two elements in a set returned to the outer query.  The values for Ref_for_Care_Coord_ID1 and Ref_for_Care_Coord_ID2 are both int as is the ct.contactid and there are rows to make the matching occur, I'm just wondering what technique I can use to make this work.

TIA
select ct.firstname, ct.lastname, ct.workphone, ct.Email
from contacts ct
where ct.contactid in (select 
                        Ref_for_Care_Coord_1ID,
                        Ref_for_Care_Coord_2ID 
                        from collaboratives 
                        where collabrecid = 30)
go

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Something like this perhaps:

select ct.firstname, ct.lastname, ct.workphone, ct.Email
from contacts ct
        LEFT JOIN collaboratives c1 On ct.contactid = c1.Ref_for_Care_Coord_1ID And c1.collabrecid = 30
        LEFT JOIN collaboratives c2 On ct.contactid = c2.Ref_for_Care_Coord_2ID ANd c2.collabrecid = 30
Avatar of dneill8

ASKER

Thanks for the fast solution!
You're welcome! Thanks for the points! Have a good week!