GROUP_CONCAT
GROUP_CONCAT([DISTINCT] expression || [expression || [expression ...]]
[ORDER BY expression [ASC|DESC], [[ORDER BY expression [ASC|DESC]]]
[SEPARATOR expression])
The expression
can be a concatenation of columns and strings using the ||
operator, for example column1 || "=" || column2
.
Parameters
DISTINCT
- filters the result set for unique sets of expressions.expression
- specifies an expression that may be a column name, a result of another function, or a math operation.ORDER BY
- orders rows by expression.SEPARATOR
- overrides a string separator. By default, the separator character is the comma ','.
The
DISTINCT
andORDER BY
expressions inside the GROUP_CONCAT function are only supported if you group the results by the primary or affinity key (i.e. useGROUP BY
). Moreover, you have to tell Ignite that your data is collocated by specifying thecollocated=true
property in the connection string or by callingSqlFieldsQuery.setCollocated(true)
if you use the Java API.
Description
Concatenates strings with a separator. The default separator is a ',' (without space). This method returns a string. If no entries are selected, the result is NULL. Aggregates are only allowed in select statements.
Example
Groups all players' names in one row:
SELECT GROUP_CONCAT(name ORDER BY id SEPARATOR ', ') FROM Players;
Updated about 5 years ago