The length of group_concat in MYSQL is limited! The default value is 1024.

Source: Internet
Author: User

The length of group_concat in MYSQL is limited! The default value is 1024.
In mysql, there is a function called "group_concat", which may not be able to detect problems during normal use. When processing big data, the content will be intercepted,
In fact, this is set internally in MYSQL. By default, the length not set is 1024. If we need a larger value, we need to manually modify the configuration file.

Details are as follows:

After group_concat is used, it does not work if limit is used in the select statement. When the group_concat is used to connect fields, there is a limit on the length, not the number of connections. But you can set it. Using group_concat_max_len system variables, you can set the maximum allowed length. The syntax for this operation in the program is as follows, where val is an unsigned integer: SET [SESSION | GLOBAL] group_concat_max_len = val; if the maximum length has been SET, the result is ended with the maximum length. Run set global group_concat_max_len = 10 in SQLyog and re-open SQLyog. The setting will take effect. ------------------------------------------------------------- GROUP_CONCAT accumulates the value of a field based on the specified characters. The default Delimiter is comma, and the length of characters that can be accumulated is 1024 bytes. You can modify these parameters. 1. Let's take a simple example: select group_concat (f_a) from t_one group by f_ B. query by f_ B and accumulate f_a in each group. 2. modify the default separator select group_concat (f_a separator '_') from t_one group by f_ B; separator is a keyword followed by the characters to be separated. sort select group_concat (f_a order by f_a separator '_') from t_one group by f_ B; 4. modify the default character size 1 ). add group_concat_max_len = 102400 In the MySQL configuration file # The maximum length you want 2 ). you can simply execute the statement and SET the scope of action to set global group_concat_max_len = 102400; set session group_concat_max_len = 102400; 5. and concat use group_concat to return a large BLOB Object by default. Use concat to return a string and add other data in the returned content.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.