Php Group by problem.
-
I have a database table and I want to retrieve table data by grouping two columns , I checked this but I was not able to find a solution ? Is there any method to do this. I want to do this from php side , not mysql
-
Not clear about your columns ? which columns you wants to group ??
-
@root root I want to group data by year and tyepe, I tried to do it using mysql. but failed.
-
Okay i'll try to find a solution .
-
@Nubelle did you get any error?
-
Did group by year,type throwed an error?
-
$array = []; //$table_data is mysql returned array, you can change this whatever you want foreach($table_data as $row) { $key = $row['type'] . '-' . $row['year']; if (!isset($array[$key])) { $array[$key] = $row; } }
Try with this , i think this is correct solution for your issue.
-
@dev_lak No when I add groupBy function mysql said to disable some features , when I disable them other functions not working
-
@KrissSachintha No when I add groupBy function mysql said to disable some features , when I disable them other functions not working
-
@root Thanks , let me try this
-
@root hi root this is working , Thanks
-
Ohh great bro, i'm very happy to help you.
-
Thanks all