0

If I have per example the following table

cliente.nome
peter sampras
john mark
monalisa

the result with

GROUP_CONCAT(DISTINCT cliente.nome ORDER BY cliente.nome SEPARATOR ', ') as client

will be:

peter sampras,john mark,monalisa

Is possible to limit the length of each item so the result is:

pete,john,mona
4

2 回答 2

1

Yes, you can use SUBSTRING or LEFT in your GROUP_CONCAT call -- I prefer using LEFT for this:

GROUP_CONCAT(DISTINCT LEFT(cliente.nome,4))

SQL Fiddle Demo

于 2013-03-22T16:16:46.583 回答
0
GROUP_CONCAT(DISTINCT SUBSTRING(cliente.nome,1,4))
于 2013-03-22T16:13:12.147 回答