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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。