以下数据库由 (select * from users) 生成。我如何根据时间显示最近的行(即我使用日期 +%s 的时间)。但这里它显示所有时间。我需要 dthe 行最近的更新时间。
| time | userid | groupid |
+------------+----------+-----------+
| 1477044791 | spolishe | MEMS |
| 1477044791 | ssarkar | HCG |
| 1477044791 | svaranas | PDSP_DES |
| 1476868065 | dnehra | HCG |
| 1476868065 | dprabhu | PDSP_DES |
我的预期输出:(但它应该是通过使用一些 linux 命令生成的,例如 date +%s)。是否有任何 linux 命令只获取最近的最近时间行(或)是否可以在 insert mysql 中使用通过存储在一些变量名中进行查询。
| time | userid | groupid |
| 1477044791 | spolishe | MEMS |
| 1477044791 | ssarkar | HCG |
| 1477044791 | svaranas | PDSP_DES |
最佳答案
您想以正确的日期格式表示时间吗? sop>
select from_unixtime(time), * from user order by time desc
关于mysql - 如何根据时间显示当前最近的行数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40177054/