group_concat function not returing all values in mysql–it returns some values with one comma at the end.

By | September 2, 2015

If you execute the below code and try to execute the query through phpmyadmin/php script. it will return only few records not all records.

you can use the below files,db sructure to check the issues

database table- create a table inside the db called ‘test’

# index.php

#connect.php

To get proper values use the below code to set the group_concat_max_len.

SET SESSION group_concat_max_len = 1000000;
select group_concat(question_id) from tbl_data where user_id=’10’

if it is in codeigniter you can use the below code in your model file

$this->db->simple_query(‘SET SESSION group_concat_max_len=1000000’);