set @sql1 = ''; SELECT GROUP_CONCAT(DISTINCT CONCAT( 'MAX(IF(field_id = ''', field_id, ''', value, NULL)) AS `', field_id,'`' ) ) INTO @sql1 FROM content_details; SET @sql1 = CONCAT('SELECT ', @sql1, ' FROM content_details GROUP BY content_id'); select @sql1; PREPARE stmt FROM @sql1; EXECUTE stmt; DEALLOCATE PREPARE stmt;
In above code @sql1 variable storing some limited characters only. Here I am concating string dynamically. I donot know the exact total length of the string what will come future. my question is how we can set the unlimited char length to the $sql1 variable. Please advice.
It sounds like you are having an issue with the GROUP_CONCAT_MAX_LEN
. You can adjust the length of this variable during your session.
The default length of this variable is 1024. You should be able to use:
set session group_concat_max_len = yourNewValue;
If you were to set this globally it would impact all other connections, that is why you might only want to set it for your session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With