Yes - use the "IN" key word.  There is no "list" to return  - simply match
the datatypes. For example, assume that X is a varchar field and y is a
varchar field:

SELECT * FROM myTable
WHERE X IN (SELECT Y FROM myTable2)


If Y returns 1 or more records, it will match them to X.

-mk

-----Original Message-----
From: Haggerty, Mike [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 08, 2002 1:32 PM
To: CF-Talk
Subject: Return a Sub-Query as a Comma Delimited List


The subject line says it all... I am writing a query for MS SQL Server and
need to return a comma delimited list of values from a subquery in the
select statement. Anyone know a way to do this?

For instance, I have a tasks table, a users table, and a reference table
linking multiple users to tasks. I want each row of the results to display
the task title along with a comma delimited list of the names of users
assigned to the task.

Normally, this is something I would do in CF by grouping the output, but in
this instance it is important to return the results without grouping them.

Any help is appreciated, thanks,

M

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Reply via email to