Display MySQL results by date

前端 未结 5 1560
眼角桃花
眼角桃花 2020-12-01 20:22

I have this mysql Table:

+--------------------+---------+-------+
|      date          | query   | count |
|--------         


        
5条回答
  •  醉话见心
    2020-12-01 21:07

    +1 good question, THIS QUESTION IS NOT SIMPLY HOW TO ORDER A QUERY!!

    I think this can be done using GROUP_CONCAT function. this will combine the matching results when you group them and seperate them by commas. ONce you have the results you can explode or do whatever you want

    http://www.w3resource.com/mysql/aggregate-functions-and-grouping/aggregate-functions-and-grouping-group_concat.php

    Your going to have to convert and group by date, and group_concat the names. then (in php or whathaveyou) explode the names by commas, and echo the date followed by the names for each result.

    edit Looks like you wanted a PHP way to solve this? oops

提交回复
热议问题