Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GROUP_CONCAT and Longtext

I need to combine two text fields in the MySQL Database table into One, So I have used the Following SQL script to do it.

Table: tbl_newsitems Combine: Need to combine the text in the 'ni_text' with the same 'news_id' Table Layout:

zNg6f

Code used to combine the text: SELECT news_id, GROUP_CONCAT(ni_text SEPARATOR ' ') FROM tbl_newsitems GROUP BY news_id;

But it won't display the full (Complete) text in the result section. The CONCAT field is trimmed and missing some text. The default Data type for the CONCAT field is TEXT (1024)

Result:

So how do I combine the whole text into one field without dropping the content. Please give me the script to do this.

Thanks

like image 456
lbo Avatar asked Jan 07 '23 21:01

lbo


1 Answers

To "fix" your group_concat issue, the server setting group_concat_max_len will need increased.

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

I believe you should be able to set it just for the session (current connection) without needing to change it globally/permanently on the server. Executing something like SET group_concat_max_len = 1000000; before your query should solve the issue.

like image 180
Uueerdo Avatar answered Jan 16 '23 20:01

Uueerdo