您的位置:首页 > 数据库 > MySQL

mysql 学习笔记

2016-01-09 18:17 627 查看
mysql去重方法可以使用函数distinct或者group by :

(1) select distinct(customer_id) from user_table;

(2) select customer_id from user_table group by customer_id;

(3)拓展:查询某时间段登录的人数
select count(distinct(customer_id)) from login_logs where logtime......
left join使用例子:

select 20160102 AS logTime, count(regNum) as aa,platform from
(
select imei as regNum,operatingsystem as platform
from RegLogs_20160102
where operatingsystem >=1 and operatingsystem<=3
group by operatingsystem,regNum
) t1
left join
(
select imei as logNum
from LoginLogs_20160102
where operatingsystem >=1 and operatingsystem<=3
group by operatingsystem,logNum
) t2
on t1.regNum = t2.logNum where t1.regNum is not null and t2.logNum is not null
group by platform;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: