Description
Currently, GroupConcat() only accepts "asc", "desc" and None for ordering parameter.
But GROUP_CONCAT supports more complex features in ORDER BY.
As an example, multiple columns and expressions:
GROUP_CONCAT(column1 ORDER BY column2, NATURAL_SORT_KEY(column3) SEPARATOR ', ') AS mycolumn
In the example above, the ordering can be done using "other" columns (column2 and column3) similar to a standard "ORDER BY". (We use the raw SQL above since GroupConcat() don't support this at the moment)
As shown in the MySQL docs:
GROUP_CONCAT([DISTINCT] expr [,expr ...]
[ORDER BY {unsigned_integer | col_name | expr}
[ASC | DESC] [,col_name ...]]
[SEPARATOR str_val])
and MariaDB docs even added LIMIT support:
GROUP_CONCAT([DISTINCT] expr [,expr ...]
[ORDER BY {unsigned_integer | col_name | expr}
[ASC | DESC] [,col_name ...]]
[SEPARATOR str_val]
[LIMIT {[offset,] row_count | row_count OFFSET offset}])
Description
Currently,
GroupConcat()only accepts "asc", "desc" and None fororderingparameter.But
GROUP_CONCATsupports more complex features in ORDER BY.As an example, multiple columns and expressions:
In the example above, the ordering can be done using "other" columns (
column2andcolumn3) similar to a standard "ORDER BY". (We use the raw SQL above since GroupConcat() don't support this at the moment)As shown in the MySQL docs:
and MariaDB docs even added
LIMITsupport: