GROUP_CONCAT and Longtext

谁说我不能喝 提交于 2019-12-12 13:26:46

问题


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:

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


回答1:


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.



来源:https://stackoverflow.com/questions/31658760/group-concat-and-longtext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!