[thelist] sql group one field
Ken Schaefer
ken.schaefer at gmail.com
Wed Sep 1 01:46:42 CDT 2004
I think this is called a "crosstab" query - something the RDBMSes
typically do not handle very well internally (because you are
essentially violating your relational design - you are turning
independant records into a single record, and making them attribute
data)
What you usually do is extra all the records into an array or similar
structure in your business layer, and do some kind of loop, and
assemble the data in the way that you want.
Some RDBMSes have stuff built-in to do this. I don't know about mySQL,
but Access does, though that's an exception rather than a rule AFAIK.
Cheers
Ken
On Tue, 31 Aug 2004 22:18:20 +0200, Richard Bennett
<richard.bennett at skynet.be> wrote:
> Hi,
>
> I am trying to extract a list from a mySQL database :
>
> I have this table:
>
> serie: model:
> 1234 abc
> 1233 abc
> 1222 abc
> 1111 def
> 1112 def
>
> I would like this result:
>
> 1234,1233,1222 abc
> 1111,1112 def
>
> Any ideas?
>
> Thanks,
> Richard.
More information about the thelist
mailing list