Trouble with GROUP_CONCAT and Longtext in MySQL

According to the MySQL manual, the maximum length of GROUP_CONCAT is defined by the group_concat_max_len system variable, which defaults to 1024. This value can be increased, by using the following command: SET group_concat_max_len = <int> It should be noted, however, that the value of group_concat_max_len is itself limited by the value of another system variable, … Read more

JPA Criteria API group_concat usage

I figured out how to do this with Hibernate-jpa-mysql: 1.) created a GroupConcatFunction class extending org.hibernate.dialect.function.SQLFunction (this is for single column group_concat for now) public class GroupConcatFunction implements SQLFunction { @Override public boolean hasArguments() { return true; } @Override public boolean hasParenthesesIfNoArguments() { return true; } @Override public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException … Read more

GROUP_CONCAT equivalent in Django

You can create your own Aggregate Function (doc) from django.db.models import Aggregate class Concat(Aggregate): function = ‘GROUP_CONCAT’ template=”%(function)s(%(distinct)s%(expressions)s)” def __init__(self, expression, distinct=False, **extra): super(Concat, self).__init__( expression, distinct=”DISTINCT ” if distinct else ”, output_field=CharField(), **extra) and use it simply as: query_set = Fruits.objects.values(‘type’).annotate(count=Count(‘type’), name = Concat(‘name’)).order_by(‘-count’) I am using django 1.8 and mysql 4.0.3

GROUP_CONCAT in SQLite

You need to add GROUP BY clause when you are using aggregate function. Also use JOIN to join tables. So try this: SELECT AI._id, GROUP_CONCAT(Name) AS GroupedName FROM ABSTRACTS_ITEM AI JOIN AUTHORS_ABSTRACT AAB ON AI.ID = AAB.ABSTRACTSITEM_ID JOIN ABSTRACT_AUTHOR AAU ON AAU._id = AAB.ABSTRACTAUTHOR_ID GROUP BY tbl._id; See this sample SQLFiddle What you were trying … Read more