This is a discussion on group_concat in MySQL within the Database Support forums, part of the Web Development category; Hi All, Code: CREATE TABLE DUMMY(ID INTEGER,X LONGTEXT); INSERT INTO DUMMY VALUES (1,1); COMMIT; Code: SELECT LENGTH('...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#41
| |||
| |||
| Hi All, Code: CREATE TABLE DUMMY(ID INTEGER,X LONGTEXT); INSERT INTO DUMMY VALUES (1,1); COMMIT; Code: SELECT LENGTH('123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT')AS Len; Code: SELECT GROUP_CONCAT('123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT') FROM DUMMY AS Result; But my String has the Length of 1457 and iam getting the length of just 1024. What may be the reason? Now i checked the Variable group_concat_max_len in my server side and i found that, Code: SELECT @@group_concat_max_len; Code: Output: 1024 Code: SET SESSION group_concat_max_len:=4294967295; -- 4 GB size; Code: SELECT GROUP_CONCAT('123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT,123PRINT,245PRINT,456PRINT') FROM DUMMY AS Result; ![]() ![]() Hope it is clear !!!!
__________________ -Murali.. |
|
#42
| |||
| |||
| Hi, CONCAT() and CONCAT_WS() function CONCAT() Function Code: Syntax CONCAT(str1,str2,...) CONCAT() returns NULL if any argument is NULL. Example: Code: SELECT CONCAT(CAST(int_col AS CHAR), char_col);
mysql> SELECT CONCAT('My', 'S', 'QL');
-> 'MySQL'
mysql> SELECT CONCAT('My', NULL, 'QL');
-> NULL
mysql> SELECT CONCAT(14.3);
-> '14.3' Code: Syntax CONCAT_WS(separator,str1,str2,...) Note: CONCAT_WS() does not skip empty strings. However, it does skip any NULL values after the separator argument. Code: mysql> SELECT CONCAT_WS(',','First name','Second name','Last Name');
-> 'First name,Second name,Last Name'
mysql> SELECT CONCAT_WS(',','First name',NULL,'Last Name');
-> 'First name,Last Name' R.Gopi. |
|
#43
| |||
| |||
| Quote:
Code: SET SESSION group_concat_max_len:=4294967295; -- 4 GB size; Just add as follows in the MYSQL config file, Code: group_concat_max_len:=4294967295; ![]()
__________________ -Murali.. |
|
#44
| |||
| |||
| Thanks for all your post, I have the same problem and now it has been sorted |
|
#45
| |||
| |||
| Hi Priyan, Im a new member. Your post was really helpfull to me. However i need to increase the max_allowed_packet and group_concat_max_len size in LINUX. But i changed the settings in /etc/my.cnf' file but the size is not changing. Again if i check the value it shows the default values. Also i would like to know, the configuration file depends on our RAM size and looks for it.. Like we have 'small', 'medium', 'large' and ;'heavy' in this which file we have to change. But i added the below given lines in my.cnf file in WINDOWS it is working fine. Please help out to solve this issue. Lines i added in 'my.cnf' file: # Set max allowed packet size to 2 MB max_allowed_packet=2M # Set group concat max length to 1 MB group_concat_max_len=1M Regards, Prabhu Rangan. Last edited by prabhurangan : 12-17-2008 at 10:00 PM. Reason: added some text to my post |
|
#46
| |||
| |||
| This function returns a string result with the concatenated non-NULL values from a group. It returns NULL if there are no non-NULL values. The full syntax is as follows: Code: GROUP_CONCAT([DISTINCT] expr [,expr ...]
[ORDER BY {unsigned_integer | col_name | expr}
[ASC | DESC] [,col_name ...]]
[SEPARATOR str_val]) Code: mysql> SELECT student_name,
-> GROUP_CONCAT(test_score)
-> FROM student
-> GROUP BY student_name; Code: mysql> SELECT student_name,
-> GROUP_CONCAT(DISTINCT test_score
-> ORDER BY test_score DESC SEPARATOR ' ')
-> FROM student
-> GROUP BY student_name; The result is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. The value can be set higher, although the effective maximum length of the return value is constrained by the value of max_allowed_packet. The syntax to change the value of group_concat_max_len at runtime is as follows, where val is an unsigned integer: Code: SET [GLOBAL | SESSION] group_concat_max_len = val; |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MySQL | lldcrb328 | PHP Programming | 2 | 02-15-2009 09:45 PM |
| I Can Help With MYSQL | theseokit | Database Support | 9 | 01-21-2009 11:01 PM |
| php-mysql | lekshmy | PHP Programming | 0 | 01-21-2009 10:58 PM |
| Why to use MySQL | Amisha_Sharma | Database Support | 1 | 01-07-2009 07:56 PM |
| multiple group_concat problem | fncll | Database Support | 4 | 11-30-2007 12:06 AM |
Our Partners |