MYSQL CONCAT MAX LENGTH

后端 未结 2 1028
轻奢々
轻奢々 2020-12-10 04:05

Following this post: POST ABOUT CONCAT My problem is that i have many rows CONCAT into one row. For example if i have 10 rows with string around 50 chars, my qu

相关标签:
2条回答
  • 2020-12-10 04:56
    You need change group_concat_max_len default value in the bellow config file   
    **my.cnf file(Linux) and my.ini file(windows)**   
    
    [mysqld]//Add this line group_concat_max_len=15000 under mysqld section
    
    group_concat_max_len=15000
    
    Note: After change is done You need to restart your MySQL server.   
    my.cnf file path in linux :   
     1. /etc/my.cnf   
    2./etc/mysql/my.cnf   
    3.$MYSQL_HOME/my.cnf   
    4.[datadir]/my.cnf   
    5.~/.my.cnf  
    
    0 讨论(0)
  • 2020-12-10 05:10

    Presumably you're using GROUP_CONCAT(), not simple CONCAT().

    The default value of the group_concat_max_len is 1024, which is a pretty small limit if you're building up big long concatenations.

    To change it, use this command. I've set the length in this example to 100,000. You could set it to anything you need.

     SET SESSION group_concat_max_len = 100000;
    

    The usual value for max_allowed_packet is one megabyte, which is likely more than you need.

    group_concat_max_len itself has an effectively unlimited size. It's limited only by the unsigned word length of the platform: 2^32-1 on a 32-bit platform and 2^64-1 on a 64-bit platform.

    If that still isn't enough for your application, it's time to take @eggyal's suggestion and rethink your approach.

    0 讨论(0)
提交回复
热议问题