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

Selecting multiple fields from a subquery, possible?

Status
Not open for further replies.

Crowley16

Technical User
Jan 21, 2004
6,931
GB
I have something like:

SELECT fld1, fld2, (SELECT fld3 FROM t2 WHERE condition)
FROM tbl2 JOIN tbl3

now, I was wondering if it's possible to include more than just the 1 field in my subquery, i.e.

SELECT fld1, fld2, (SELECT fld3, fld4 FROM t2 WHERE condition)
FROM tbl2 JOIN tbl3



--------------------
Procrastinate Now!
 
I've sorted it now...

Used a JOIN instead of the subquery, which seems to work...

--------------------
Procrastinate Now!
 
To answer your question, a subquery in a SELECT clause needs to return a single value so you would need a separate subquery for each field. However, you can usually change the query to join the table which is more efficient anyway.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top