Summarizing a column to a DISTINCT value

Hey folks,
I am just getting into MySQL and have run into a problem with
subqueries.
I am running MySQL 4.0.21 and I am trying to CONCAT and I have no idea
where I'm tripping up...

The data looks like this....

+----+------------+---------+
| id | product | color |
+----+------------+---------+
| 1 | mixer | blue |
| 2 | mixer | green |
| 3 | mixer | yellow |
+----+------------+

I need to generate this....
+----+------------+---------+
| id | product | color |
+----+------------+---------+
| 1 | mixer | blue/green/yellow |
+----+------------+

In short, for each distinct product, generate a color field where the
all the choices are concatenated by a slash.

My apologies if this is remarkably simple. The real world query is
actually more brutal than this one which I have reduced for simplicity.

Sherabg
worldcyclist [ Sa, 09 September 2006 20:52 ] [ ID #1460566 ]

Re: Summarizing a column to a DISTINCT value

worldcyclist [at] gmail.com wrote:
> Hey folks,
> I am just getting into MySQL and have run into a problem with
> subqueries.
> I am running MySQL 4.0.21 and I am trying to CONCAT and I have no idea
> where I'm tripping up...
>
> The data looks like this....
>
> +----+------------+---------+
> | id | product | color |
> +----+------------+---------+
> | 1 | mixer | blue |
> | 2 | mixer | green |
> | 3 | mixer | yellow |
> +----+------------+
>
> I need to generate this....
> +----+------------+---------+
> | id | product | color |
> +----+------------+---------+
> | 1 | mixer | blue/green/yellow |
> +----+------------+
>
> In short, for each distinct product, generate a color field where the
> all the choices are concatenated by a slash.
>
> My apologies if this is remarkably simple. The real world query is
> actually more brutal than this one which I have reduced for simplicity.
>
> Sherabg

So what does your query for this hypothetical problem look like?
zac.carey [ So, 10 September 2006 13:43 ] [ ID #1461229 ]
Datenbanken » mailing.database.mysql » Summarizing a column to a DISTINCT value

Vorheriges Thema: Access MySQL command line history in WinXP
Nächstes Thema: Storing and retreiving rich text from MySQL to rich textbox