Yes, I've used this solution several times, but the data is destined for
Excel/Microsoft Query, so a CF-centric choice won't work.  Thanks, though!

Josh

> -----Original Message-----
> From: Dave Watts [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 25, 2003 11:04 AM
> To: CF-Talk
> Subject: RE: Strange SQL Question
>
>
> > Is it possible on a database with two tables in a one-to-many
> > relationship to grab the many and stick them all in one field?
> > Let me elaborate:
> >
> > I have a Contract table which contains all the header
> > information for a particular contract. Then I have a Printer
> > table which has all the printers on contracts, which reference
> > the ContractID.
> >
> > What I'd like to do is get certain header information out of
> > the Contract, and say, a comma-separated list of Serial Numbers
> > from the Printer table that are for that contract.
> >
> > I know how to do this querying twice, what I want to know is if
> > it's possible to do this querying once.
>
> If by "stick them all in one field", you mean "display them as a
> comma-separated list in your output", you can do this pretty easily within
> your output code using the CFOUTPUT tag's GROUP attribute. In your query,
> just join the tables as you normally would, and ORDER BY ContractID. Then,
> in your output, do something like this:
>
> <cfoutput query="qContractsAndPrinters" group="ContractID">
> #ContractID#:
>       <cfset SNList = "">
>       <cfoutput>
>               <cfset SNlist = ListAppend(SNList, SerialNumber)>
>       </cfoutput>
>       #SNList#<br>
> </cfoutput>
>
> It's kind of a hack, I guess, but it's pretty simple.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
> voice: (202) 797-5496
> fax: (202) 797-5444
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to