mysql有这么一个表
t_article 文章表
id integer id 文章id
article varchar(100) 文章名称
op_user varchar(50) 操作用户
create_time datetime 文章发布时间
id article op_user create_time
1 a zhangsan 2016-01-01 17:45:17
2 b lisi 2016-01-01 15:25:12
3 c zhangsan 2016-01-02 10:11:00
当sql是
select count(1), op_user from t_article where create_time like “”2016-01-01%”” group by op_user 时可以得出
count(1) op_user
1 zhangsan
1 lisi
可是sql变成
select count(1), op_user from t_article where create_time like “”2016-01-02%”” group by op_user 时
结果是
count(1) op_user
1 zhangsan
可是本人期待的结果是
count(1) op_user
1 zhangsan
0 lisi
该怎么做
t_article 文章表
id integer id 文章id
article varchar(100) 文章名称
op_user varchar(50) 操作用户
create_time datetime 文章发布时间
id article op_user create_time
1 a zhangsan 2016-01-01 17:45:17
2 b lisi 2016-01-01 15:25:12
3 c zhangsan 2016-01-02 10:11:00
当sql是
select count(1), op_user from t_article where create_time like “”2016-01-01%”” group by op_user 时可以得出
count(1) op_user
1 zhangsan
1 lisi
可是sql变成
select count(1), op_user from t_article where create_time like “”2016-01-02%”” group by op_user 时
结果是
count(1) op_user
1 zhangsan
可是本人期待的结果是
count(1) op_user
1 zhangsan
0 lisi
该怎么做
解决方案:40分
建立一张用户表, 用户表去左连接文章表即可