GROUP_CONCAT和Longtext [英] GROUP_CONCAT and Longtext

查看:87
本文介绍了GROUP_CONCAT和Longtext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将MySQL数据库表中的两个文本字段合并为一个,因此我使用了以下SQL脚本来完成它。

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.

表:tbl_newsitems
Combine:需要将'ni_text'中的文本与相同的'news_id'
表布局:

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

用于合并文本的代码:
SELECT
news_id
GROUP_CONCAT( ni_text
分隔符'')
来自
tbl_newsitems
GROUP BY news_id ;

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

但它不会显示完整(完整)结果部分中的文本。 CONCAT字段被修剪并缺少一些文本。 CONCAT字段的默认数据类型为TEXT(1024)

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)

结果:

所以我如何将整个文本合并到一个字段中而不删除内容。

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

谢谢

推荐答案

要修复您的 group_concat 问题,服务器设置 group_concat_max_len 将需要增加。

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

MySQL 5.7参考手册/ ... /服务器系统变量

我相信您应该能够为会话设置它(当前连接),而无需在服务器上全局/永久更改它。在查询之前,应先执行 SET group_concat_max_len = 1000000; 之类的问题。

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.

这篇关于GROUP_CONCAT和Longtext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆