GROUP_CONCAT and Longtext
Asked Answered
A

1

6

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

Ascanius answered 27/7, 2015 at 16:45 Comment(1)
Can you paste your create table statement and some example data on sqlfiddle -> sqlfiddle.com?Hidebound
K
11

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.

Kildare answered 27/7, 2015 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.