mysql 语句 GROUP_CONCAT
select * from blog_log;
+----+---------------------+-------+--------+
| id | time | level | info |
+----+---------------------+-------+--------+
| 1 | 2011-11-11 23:32:32 | 1 | haha |
| 2 | 2012-12-12 12:21:21 | 1 | haha |
| 3 | 2013-12-12 12:12:12 | 1 | hehe |
| 4 | 2013-02-12 12:12:12 | 2 | haha |
| 5 | 2013-12-02 12:12:12 | 2 | hehe |
| 6 | 2013-12-02 13:12:12 | 2 | hehe |
| 7 | 2016-12-02 12:12:12 | 2 | hehe |
| 8 | 2013-12-25 12:12:12 | 1 | haha |
| 9 | 2011-11-11 23:32:32 | 3 | hahage |
| 10 | 2001-11-11 23:32:32 | 5 | hahage |
+----+---------------------+-------+--------+
SELECT level, info, GROUP_CONCAT(time ORDER BY time DESC SEPARATOR " | ") AS time, COUNT(1) AS count FROM blog_log GROUP BY level, info ORDER BY time DESC, count DESC
-> ;
+-------+--------+-----------------------------------------------------------------+-------+
| level | info | time | count |
+-------+--------+-----------------------------------------------------------------+-------+
| 2 | hehe | 2016-12-02 12:12:12 | 2013-12-02 13:12:12 | 2013-12-02 12:12:12 | 3 |
| 1 | haha | 2013-12-25 12:12:12 | 2012-12-12 12:21:21 | 2011-11-11 23:32:32 | 3 |
| 1 | hehe | 2013-12-12 12:12:12 | 1 |
| 2 | haha | 2013-02-12 12:12:12 | 1 |
| 3 | hahage | 2011-11-11 23:32:32 | 1 |
| 5 | hahage | 2001-11-11 23:32:32 | 1 |
+-------+--------+-----------------------------------------------------------------+-------+