首页 > 代码库 > MySQL DISTINCT
MySQL DISTINCT
DISTINCT(COL)用来对结果去除重复
比如表内容如下:
SELECT DISTINCT(id) FROM yww_test
下面的例子实现:选择过去一天,没有出现过的数据
-- 统计最原始的未上线采集数据,准备和其他表合并 DROP VIEW if EXISTS `unconnected_elemeterhead`; CREATE VIEW unconnected_elemeterhead AS SELECT DATE_SUB(curdate() , INTERVAL 1 DAY) as 'uhead_date', head.`NAME` as 'uhead_name', head.PADDRESS as head_address, head.E_BUREAU_ID as bureau_id, head.ID as 'uhead_id' FROM e_elemeterhead_link39 AS head WHERE head.`STATUS` = 0 AND head.ID NOT IN ( SELECT DISTINCT (a.E_ELEMETERHEAD_ID) FROM e_eledata AS a WHERE to_days(now()) - to_days(a.DLDT) = 1 );注意:如何确定昨天,如何统计未出现的ID
MySQL DISTINCT
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。