472,101 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,101 software developers and data experts.

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

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

Feb 14 '06 #1
2 1657
<ph**************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.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.
Feb 15 '06 #2

Bill Karwin wrote:
<ph**************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.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.


Feb 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by 4partee | last post: by
reply views Thread by gmorris | last post: by
5 posts views Thread by Guillermo Antonio Amaral Bastidas | last post: by
bilibytes
1 post views Thread by bilibytes | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.