Why does GROUP_CONCAT() function fail in MySQL 4.1.12 in this query?

Why does GROUP_CONCAT() function fail in MySQL 4.1.12 in this query?

am 15.02.2006 00:33:36 von phillip.s.powell

Here are my results using MySQL 4.1.12 and I honestly don't think this
is right, but can't figure out what to do:

mysql> select id, group_concat(DISTINCT school_enrollment_time_name
SEPARATOR ',') as school_enrollment_time_display from
school_enrollment_time group by id;
+----+--------------------------------+
| id | school_enrollment_time_display |
+----+--------------------------------+
| 1 | spring |
| 2 | summer |
| 3 | fall |
+----+--------------------------------+
3 rows in set (0.00 sec)

mysql> select id, school_enrollment_time_name from
school_enrollment_time;
+----+-----------------------------+
| id | school_enrollment_time_name |
+----+-----------------------------+
| 1 | spring |
| 2 | summer |
| 3 | fall |
+----+-----------------------------+
3 rows in set (0.00 sec)

I need help in a hurry on this one, thanx
Phil

Re: Why does GROUP_CONCAT() function fail in MySQL 4.1.12 in this query?

am 15.02.2006 01:18:31 von Bill Karwin

wrote in message
news:1139960016.056024.160660@g47g2000cwa.googlegroups.com.. .
> Here are my results using MySQL 4.1.12 and I honestly don't think this
> is right, but can't figure out what to do:
>
> mysql> select id, group_concat(DISTINCT school_enrollment_time_name
> SEPARATOR ',') as school_enrollment_time_display from
> school_enrollment_time group by id;

You're grouping by id, which I assume is a unique key.
So the groups are all guaranteed to be groups of exactly one row.

GROUP BY is traditionally used on fields in which values occur multiple
times.

Regards,
Bill K.

Re: Why does GROUP_CONCAT() function fail in MySQL 4.1.12 in this query?

am 15.02.2006 17:53:48 von phillip.s.powell

Bill Karwin wrote:
> wrote in message
> news:1139960016.056024.160660@g47g2000cwa.googlegroups.com.. .
> > Here are my results using MySQL 4.1.12 and I honestly don't think this
> > is right, but can't figure out what to do:
> >
> > mysql> select id, group_concat(DISTINCT school_enrollment_time_name
> > SEPARATOR ',') as school_enrollment_time_display from
> > school_enrollment_time group by id;
>
> You're grouping by id, which I assume is a unique key.
> So the groups are all guaranteed to be groups of exactly one row.

id is a unique key, therefore, how will it be done to have a single row
consisting of the following:

if I selected ids (1, 2) then I would see the following string:
spring,summer
if I selected ids (1, 3) then I would see the followings tring:
spring,fall

Etc.

Phil

>
> GROUP BY is traditionally used on fields in which values occur multiple
> times.
>
> Regards,
> Bill K.