返回信息流题目说的不明确,下面细说:
现有一张pk比赛表,内含字段比赛发起人a,比赛接收人b,现在需要知道一共某一天有多少人参与了pk赛。也就是说要把那一天里面a和b中所有不同的元素统计出来,该怎么操作。
时间部分我是这么解决的,应该木有问题吧:
where date_format(from_unixtime(intime),'%Y%m%d') = date_format(date_sub(curdate(), interval %d day), '%Y%m%d');
我初学MySQL,有些整不明白,还希望各位帮忙,谢谢!
这是一条镜像帖。来源:北邮人论坛 / database / #8561同步于 2014/11/18
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Database机器人发帖
MySQL查询一张表中两个字段所有不同元素问题
weiowen
2014/11/18镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
怎么个distinct法呢 如果你是说这样:
select count(distinct(a)) from table
select count(distinct(b)) from table
这样只能在发起方和接受方区分不重复的情况,没有排除某一发起方是另一场PK赛的接受方这种情况吧
【 在 CallMeCorpse 的大作中提到: 】
: distinct 不行吗?
可以用子查询吧 类似于这样子select distinct (user) from (select distinct(usera) as user from table UNION ALL select distinct(userb) as user from table)
select acolumn1 from tableName union distinct select column2 from tableName;