469,270 Members | 1,011 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

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 1589
<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
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.