ExampleTable的datetime时间列, 如果datetime不一样的,找到最大的,要是有3个一样最大都列出来。 如果datetime一样就都列出来。我用了MAX()函数,它只能返回一行这样的结果。SELECT MAX(datetime) FROM ExampleTable WHERE id=333;+---------------------+
| MAX(datetime) |
+---------------------+
| 2001-08-28 07:34:00 |
+---------------------+
1 row in set (0.00 sec)而我想要的结果是:
+---------------------+
| datetime|
+---------------------+
| 2001-08-28 07:34:00 |
| 2001-08-28 07:34:00 |
+---------------------+还望高手帮忙给个提示
| MAX(datetime) |
+---------------------+
| 2001-08-28 07:34:00 |
+---------------------+
1 row in set (0.00 sec)而我想要的结果是:
+---------------------+
| datetime|
+---------------------+
| 2001-08-28 07:34:00 |
| 2001-08-28 07:34:00 |
+---------------------+还望高手帮忙给个提示
解决方案 »
- MYSQL 怎么模糊搜索啊。咋我实现不了的
- postgresql时间戳问题
- oralce语句转mysql
- MYSQL函数问题!急啊。。。急啊。。。。
- postgresql 存储结构返回问题
- is not allowed to connect to this MySQL server 问题??
- mysql-client是不是MYSQL的客户端工具?
- mysql主从再做读写分离后,主从复制的延迟对插入或更新一条记录后再查询这条记录的影响有多大呢?我没有再生产中研究这个问题
- MySQL执行存储过程中出现错误1305 - FUNCTION cr_debug.ENTER_MODULE2 does not exist
- 请问怎么比较mysql两张表的数据是否一致
- 请教一个SQL删除语句。。
- select like 问题?
from ExampleTable
where id=333
and `datetime` = (select max(`datetime`) from ExampleTable where id=333 );
from ExampleTable a
where id=333
and not exists (select id from ExampleTable where id=a.id and `datetime`>a.`datetime`);
datetime 是保留字,不建议做为列名。
(select max(`datetime`) as ma from ExampleTable where id=333) b on a.`datetime`=b.ma
Subquery returns more than 1 row
select * from file_table where fvid=29823
and modifytime = (select modifytime from file_table where fvid=29823 );