Length limit - concat and group_concat

Length limit - concat and group_concat

by Jay H. -
Number of replies: 3

Hello,

I would like to create a query:

From each teacher I want to show all his courses with the urls of the courses. 

If I query  the course name or ID for the courses, there is a difference of the result. As soon as I use Group_Concat or concat not all courses are displayed. Are there any restrictions on the number of characters here? 

SELECT concat (u.firstname, " ", u.lastname) as trainer,
GROUP_CONCAT(c.fullname, ' </br>') as course,  # incomplete list of courses
GROUP_CONCAT(c.id, ' </br>') as course2,      # complete list of course-ids
u.auth
FROM prefix_course AS c
JOIN prefix_context AS ctx ON c.id = ctx.instanceid
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id and ra.roleid= 3
JOIN prefix_user AS u ON u.id = ra.userid
Group BY u.id


Average of ratings: -
In reply to Jay H.

Re: Length limit - concat and group_concat

by Randy Thornton -
Picture of Documentation writers
Yes, there is a restriction.

The default length is 1024. Official documentation and how to up that are here: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat as well as some other ways of doing it in the accepted answer to this post: https://stackoverflow.com/questions/12001919/mysql-truncates-concatenated-result-of-a-group-concat-function
Average of ratings: Useful (2)
In reply to Randy Thornton

Re: Length limit - concat and group_concat

by Jay H. -
Thanks for the quick reply and the helpful links!
In reply to Jay H.

Re: Length limit - concat and group_concat

by Randy Thornton -
Picture of Documentation writers
No worries. I ran into this exact issue myself about a year ago and the solution was to up the number in the mysql.ini file.