select from_unixtime(logtime) as logtime,id from t_log where id in (select id from t_acc) order by logtime desc limit 0,1;这个Sql得到的内容为:
+---------------------+-----------+
| logtime | id |
+---------------------+-----------+
| 2009-08-16 01:59:17 | 514000 |
+---------------------+-----------+我要得到的每个ID的最后一条登录时间现在只能得到t_log中的最后一条信息。。
请问要怎么修改呀?
+---------------------+-----------+
| logtime | id |
+---------------------+-----------+
| 2009-08-16 01:59:17 | 514000 |
+---------------------+-----------+我要得到的每个ID的最后一条登录时间现在只能得到t_log中的最后一条信息。。
请问要怎么修改呀?
2楼的。。那个。。Sql没问题嘛?select * from unixtime(logtime) as logtime,id from t_log这个看不懂。。没写错嘛?
from t_log
where id in (select id from t_acc)
group by id
不就是求每个ID是最后一次登陆时间吗?
等价于每个ID的最大时间
select from_unixtime(logtime) as logtime,id from t_log a, t_acc b,(select id,max(logtime) as logtime2 from t_log group by id) c where a.id=b.id and a.id=c.id and a.logtime=c.logtime2写法3:select from_unixtime(a.logtime) as logtime,a.id from t_log a where a.id in (select b.id from t_acc b) and a.logtime=(select max(c.logtime) from t_log c where c.id=a.id)