mysql - 如何根据时间显示当前最近的行数?

标签 mysql linux


以下数据库由 (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/

相关文章:

mysql - 如何在MySQL数据库中创建复合键

php - 需要帮助创建触发器 phpmyadmin

php - Mysql触发器中的多个IF不起作用

php - 结合PHP和MYSQL使用javascript函数和变量

c - mmap 无效参数错误

c++ - Linux 共享库中缺少函数

linux - 在自修改汇编代码中调用 mprotect 后仍然出现段错误

linux - 并行计算中的pthreading

php - mysqli_query 仅在存在 WHERE 语句时返回结果

linux - 如何解释%gs :0x14?