Bug #3543 | Subquery GROUP_CONCAT does not work properly | ||
---|---|---|---|
Submitted: | 22 Apr 2004 13:18 | Modified: | 5 May 2004 18:17 |
Reporter: | Daniel Grace | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | mysql-4.1.1-alpha-standard (Official) | OS: | Linux (Linux bassett-dell 2.2.18) |
Assigned to: | Timothy Smith | CPU Architecture: | Any |
[22 Apr 2004 13:18]
Daniel Grace
[5 May 2004 18:09]
Timothy Smith
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.mysql.com/documentation/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php Additional info: In the query, GROUP_CONCAT() is used in a (sub-)query that does not have any GROUP clause. The GROUP clause in the external query doesn't apply to the internal query. It simply GROUPs on c.id, which is always unique already. E.g., run the sub-query on its own: mysql> select group_concat(e.name separator "; ") from course_membership cm, entity e where cm.entityid=e.id and cm.courseid = 1; +-------------------------------------+ | group_concat(e.name separator "; ") | +-------------------------------------+ | Teacher 1 | +-------------------------------------+ 1 row in set (0.33 sec) That's all that is happening in your query....
[5 May 2004 18:17]
Timothy Smith
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release. If necessary, you can access the source repository and build the latest available version, including the bugfix, yourself. More information about accessing the source trees is available at http://www.mysql.com/doc/en/Installing_source_tree.html Additional info: Daniel, Sorry about that - I misread the main point of your report. When I try it, I get: mysql> SELECT c.id, c.title, (SELECT GROUP_CONCAT(e.name SEPARATOR "; ") FROM course_membership cm, entity e WHERE cm.entityid=e.id AND cm.courseid=c.id) AS teachers FROM course c LIMIT 2,5; +----+-----------+-----------+ | id | title | teachers | +----+-----------+-----------+ | 3 | Course 1C | Teacher 1 | | 4 | Course 2A | Teacher 2 | | 5 | Course 2B | Teacher 2 | +----+-----------+-----------+ 3 rows in set (0.00 sec) That looks correct to me - this is something that's fixed in 4.1.2.