1.distinct select count(distinct CName) from teble select count(CName) from (select distinct CName from Course) as temp SELECT DISTINCT text_zhcn FROM dms_menuconfig -- 去重查询表中数据 select DISTINCT(user_id) from user_info where children_merchant_id='kuai…
一.去重 1.查询出重复的记录 CREATE TABLE push_log_full_2013_10_30_tmp SELECT * FROM `push_log_full` WHERE time BETWEEN FROM_DAYS(TO_DAYS(NOW()) - 1) AND FROM_DAYS(TO_DAYS(NOW())) AND (imsi, andriodid, time) IN ( SELECT imsi, andriodid, time FROM `push_log_full`…
参考资料:http://blog.csdn.net/guocuifang655/article/details/3993612 方法一: 在使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提供 有distinct这个关键字来过滤掉多余的重复记录只保留一条,但往往只用它来返回不重复记录的条数,而不是用它来返回不重记录的所有值.其原因是 distinct只能返回它的目标字段,而无法返回其它字段 下面先来看看例子: table id name 1 a 2 b …
delete from 表名 where id not in (select d.id from (SELECT id FROM 表名 GROUP BY c1,c2,c3,c4)as d) #去重复,把url重复,且区为空的中去掉.select * from TABLE where url in (select u.url from (select * from TABLE where id not in (select d.id from (SELECT id FROM TABLE GROUP…
1.distinct一般用于获取不重复字段的条数 使用原则: 1)distinct必须放在要查询字段的开头,不能放在查询字段的中间或者后面 select distinct name from user; 获取不重名的name 记录 select id, distinct name from user; 这种写法是错误的,distinct只能写在所有查询字段的前面 2)distinct 对后面所有的字段均起作用,即去重是查询的所有字段完全重复的数据,而不是只对 distinct后面连接的单个字段重…
select a.id,a.ssmz,(select count(ssmz) from shop_tourist_key b where b.ssmz=a.ssmz) as count from shop_tourist_key a WHERE a.ssmz is not null group by a.ssmz LIMIT 0,3; select a.id,a.ssmz,(select count(ssmz) from shop_tourist_key b where…