Have a look at Hal Helms' May newsletter:

http://www.halhelms.com/index.cfm?fuseaction=newsletters.may2001

(The Return of Mr SQL :-))

-----Original Message-----
From: John Quarto-vonTivadar [mailto:[EMAIL PROTECTED]]
Sent: 29 November 2001 06:20
To: CF-Talk
Subject: brain fart: some simple SQL


hello everyone,
well, it's 1 am and I'm having a brainfart on something that is relatively
simple:

I've got a simple LEFT JOIN, where i retrieve the UserID and the ServiceID's
of Services that User needs. Since they are realted through a many-2-many
relationship, I get something like


UserID      ServiceID
1                   402
1                   417
1                    533
2                   200
2                   201
3                   {null}

ok, no problem. What I *REALLY* want in the result set is for the ServiceID
to be turned into a list, something like:

UserID      ServiceIDs
1                402,417,533
2                200,201
3                {null}

Yeah, it's easy, but inefficient, to do with CF but how can I make SQL do
this for me (esp with the {null})?  It's gonna turn out to be something easy
that I've seen before, but I haven't had to write something like this for
like a year and now I'm drawing a one in the morning blank. Is it a GROUP BY
thing? or a sub-query thing?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to