Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
680 views
in Technique[技术] by (71.8m points)

sql - MySQL Truncating of result when using Group_Concat and Concat

I have the following SQL (I have removed some of the selesct fi:

SELECT node_revisions.title                          AS 'Task', 
       node_revisions.body                           AS 'Description', 
       Date_format(field_due_date_value, '%e/%c/%Y') AS 'Due Date', 
       users.name                                    AS 'User Name', 
       (SELECT GROUP_CONCAT(Concat(CHAR(10),Concat_ws( ' - ', name, From_unixtime( TIMESTAMP, 
               '%e/%c/%Y' )),CHAR(10),COMMENT))
        FROM   comments 
        WHERE  comments.nid = content_type_task.nid) AS 'Comments' 
FROM   content_type_task 
       INNER JOIN users 
         ON content_type_task.field_assigned_to_uid = users.uid 
       INNER JOIN node_revisions 
         ON content_type_task.vid = node_revisions.vid 
ORDER  BY content_type_task.nid DESC 

This pulls back all my tasks and all comments associated with a task. The problem I am having is that the comments field; created using the *GROUP_CONCAT*, is truncating the output. I don't know why and I don't know how to overcome this. (It looks to be at 341ish chars)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

GROUP_CONCAT() is, by default, limited to 1024 bytes.

To work around this limitation and allow up to 100 KBytes of data, add group_concat_max_len=102400 in my.cnf or query the server using SET GLOBAL group_concat_max_len=102400.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...