GROUP_CONCAT and Longtext

I need to concatenate two text fields in a MySQL database table in One, so I used the following SQL script to do it.

Table: tbl_newsitems Combine: need to concatenate text in "ni_text" with the same "news_id", Table layout:

zNg6f

Code used to combine text: SELECT    news_id

  GROUP_CONCAT ( ni_text

  SEPARATOR ') FROM tbl_newsitems GROUP BY news_id

;

But it will not display the full (complete) text in the results section. The CONCAT field is truncated and skips some text. The default data type for the CONCAT field is TEXT (1024)

Result:

So how do I combine all the text into one field without discarding the content. Please give me a script for this.

thank

+3


source to share


1 answer


To "fix" the problem with group_concat

, you must set the value of the server parameter group_concat_max_len

.

MySQL 5.7 Reference Manual /.../ Server System Variables



I believe you should only set it for the session (current connection), without changing it globally / permanently on the server. Doing something like SET group_concat_max_len = 1000000;

before your query should fix the problem.

+6


source







All Articles