NYCPHP Meetup

NYPHP.org

[nycphp-talk] mysql question

David Mintz dmintz at davidmintz.org
Tue Aug 23 10:44:29 EDT 2005


On Tue, 23 Aug 2005, Frank Wong wrote:

> Marcin Szkudlarek wrote:
>
> >I have a simple table like this
> >
> >create table numbers (user int, number int);
> >insert into numbers (user, number) values (1, 1);
> >insert into numbers (user, number) values (1, 9);
> >insert into numbers (user, number) values (1, 5);
> >
> >is it possible in mysql to write a query which gives me a result (1 row):
> >"1,9,5" ?
> >
> >Marcin
> >
> >
> As far as I know, that cannot be done with a single query.  Your best
> bet is to query (SELECT number FROM numbers) then programatically get
> your results to the comma delimited format you want.  It can also be
> done using stored procedures if the database you are using supports
> stored procedures.

I would bet there is some really perverse virtuoso contortion you could do
involving concat() and sub-SELECTs, but yeah, go with doing it
programmatically.

Haiku, anyone?


---
David Mintz
http://davidmintz.org/



More information about the talk mailing list