mysql连续查询相同表格进行比较

来源:互联网 发布:淘宝价格监控插件 编辑:程序博客网 时间:2024/05/29 19:20

连续查询2个表的时候,可以用sql语句进行比较。。。比如可以查询一个表里面第一天多少玩家登陆,第二天这些玩家再次登陆有多少个,到第三天、第四天。。。。

  select count(a.user_id) from 
(
 select distinct uid from log_login where logtime>=unix_timestamp('2014-1-1 00:00:00') and logtime<unix_timestamp('2014-1-2 00:00:00')
) a
left join
(
 select distinct uid from log_login where logtime>=unix_timestamp('2014-1-2 00:00:00') and logtime<unix_timestamp('2014-1-3 00:00:00')
) b
on a.uid = b.uid
where b.uid is not null

0 0