有一组数据select archiveid, filetime, filename , status
from file_table
order by filename ASC;
+-----------+---------------------+----------+--------+
| id| filetime| filename | status |
+-----------+---------------------+----------+--------+
| 1 | 2014-05-21 01:24:24 | c1.txt | 1 |
| 8 | 2014-05-23 01:24:24 | c1.txt | 1 |
| 10 | 2014-05-21 04:24:26 | c2.txt | 1 |
| 2 | 2014-05-21 01:24:25 | c3.txt | 1 |
| 9 | 2014-05-21 02:24:25 | c3.txt | 1 |
| 3 | 2014-05-21 01:24:26 | c4.txt | 1 |
| 5 | 2014-05-21 03:24:26 | c4.txt | 1 |
| 6 | 2014-05-21 05:24:26 | c4.txt | 1 |
| 7 | 2014-05-22 01:24:26 | c4.txt | 1 |
+-----------+---------------------+----------+--------+数据库file_table表有4组文件,c1 ~ c4.txt,录入的时间filetime列不一样,每组文件将最大时间的status位设置成3。 求查询语句。期待结果+-----------+---------------------+----------+--------+
| id| filetime| filename | status |
+-----------+---------------------+----------+--------+
| 1 | 2014-05-21 01:24:24 | c1.txt | 1 |
| 8 | 2014-05-23 01:24:24 | c1.txt | 3 |
| 10 | 2014-05-21 04:24:26 | c2.txt | 3 |
| 2 | 2014-05-21 01:24:25 | c3.txt | 1 |
| 9 | 2014-05-21 02:24:25 | c3.txt | 3 |
| 3 | 2014-05-21 01:24:26 | c4.txt | 1 |
| 5 | 2014-05-21 03:24:26 | c4.txt | 1 |
| 6 | 2014-05-21 05:24:26 | c4.txt | 1 |
| 7 | 2014-05-22 01:24:26 | c4.txt | 3 |
+-----------+---------------------+----------+--------+
from file_table
order by filename ASC;
+-----------+---------------------+----------+--------+
| id| filetime| filename | status |
+-----------+---------------------+----------+--------+
| 1 | 2014-05-21 01:24:24 | c1.txt | 1 |
| 8 | 2014-05-23 01:24:24 | c1.txt | 1 |
| 10 | 2014-05-21 04:24:26 | c2.txt | 1 |
| 2 | 2014-05-21 01:24:25 | c3.txt | 1 |
| 9 | 2014-05-21 02:24:25 | c3.txt | 1 |
| 3 | 2014-05-21 01:24:26 | c4.txt | 1 |
| 5 | 2014-05-21 03:24:26 | c4.txt | 1 |
| 6 | 2014-05-21 05:24:26 | c4.txt | 1 |
| 7 | 2014-05-22 01:24:26 | c4.txt | 1 |
+-----------+---------------------+----------+--------+数据库file_table表有4组文件,c1 ~ c4.txt,录入的时间filetime列不一样,每组文件将最大时间的status位设置成3。 求查询语句。期待结果+-----------+---------------------+----------+--------+
| id| filetime| filename | status |
+-----------+---------------------+----------+--------+
| 1 | 2014-05-21 01:24:24 | c1.txt | 1 |
| 8 | 2014-05-23 01:24:24 | c1.txt | 3 |
| 10 | 2014-05-21 04:24:26 | c2.txt | 3 |
| 2 | 2014-05-21 01:24:25 | c3.txt | 1 |
| 9 | 2014-05-21 02:24:25 | c3.txt | 3 |
| 3 | 2014-05-21 01:24:26 | c4.txt | 1 |
| 5 | 2014-05-21 03:24:26 | c4.txt | 1 |
| 6 | 2014-05-21 05:24:26 | c4.txt | 1 |
| 7 | 2014-05-22 01:24:26 | c4.txt | 3 |
+-----------+---------------------+----------+--------+
解决方案 »
- mysql+jsp为什么总是说用户名或密码错误?
- mysql数据库,乱码解决办法汇总
- 关于mysql select*走非聚集索引的疑惑
- 用mysql GUI tool备份问题
- jsp与mysql的连接??
- 程序连接postgresql数据只能用localhost连,用IP地址连接或机器名就没有用,请问怎么设置?
- 请问如何使MySql中的数据库能支持事务,MySql它支持事务吗?
- 用phpmyadmin怎样使进入index.php页面的时候输入用户名和密码?
- mysql死翘翘啦
- 先分割字符再比较大小的SQL语句怎么写??
- 求教:MYSQL正则表达式的字段是否需要索引,求高手指教
- insert 嵌套的问题,请各位老师帮忙
from file_table A
[征集]分组取最大N条记录方法征集,及散分....