mysql> select * from test;
+----+--------+------+------------+---------+
| id | title | tag | date | content |
+----+--------+------+------------+---------+
| 38 | title1 | xx | 1514521364 | 1 |
| 39 | title2 | xx | 1514521365 | 1 |
| 40 | title3 | xx | 1514521366 | 1 |
| 41 | title4 | xx | 1514521367 | 2 |
| 42 | title5 | xx | 1514521368 | 2 |
+----+--------+------+------------+---------+
5 rows in set (0.01 sec)
this is my test table. l need get the result like follow:
+----+--------+------+------------+---------+
| id | title | tag | date | content |
+----+--------+------+------------+---------+
| 40 | title3 | xx | 1514521366 | 1 |
| 42 | title5 | xx | 1514521368 | 2 |
+----+--------+------+------------+---------+
l group by content
field, and need select row by max(date)
, because l need the id
field correct.
sql may like select id, max(date), content from test group by content;
l tried some way, but failed. l really a rookie in mysql.