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’
1 2 3 4 5 |
CREATE TABLE IF NOT EXISTS `tbl_data` ( `id` int(10) NOT NULL, `question_id` int(10) NOT NULL, `user_id` int(10) NOT NULL ) |
# index.php
1 2 3 4 5 6 7 8 9 10 |
<?php include"connect.php"; for($i=0;$i<1500;$i++) { $query="insert into tbl_data(question_id,user_id) values('$i','10')"; $result=mysql_query($query,$linkfirst); } ?> |
#connect.php
1 2 3 4 5 6 7 8 |
<?php $linkfirst = mysql_connect('localhost', 'root', ''); if (!$linkfirst) { die('Could not connect: ' . mysql_error()); } mysql_select_db('test', $linkfirst) or die('Could not select database.'); ?> |
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’);
Pingback: group_concat function not returning all values. one extra comma adding at the end of the data | Ask your technical doubts here::Answer will get you in your finger tips.()