清除

################ o_device 脏数据 ########################

select DISTINCT(deviceid) from o_device a where a.deviceid in (select deviceid from o_device where `status`='0' GROUP BY deviceid having count(deviceid) > 1) and a.`status`='0'
         
update o_device set `status`='1' where `status`='0' and deviceid=#deviceid# and did not in (select did from (select max(did) did from o_device where `status`='0' and deviceid=#deviceid#) a);

###########################################################


############ o_device_profile 脏数据 ####################

select DISTINCT(deviceid) from o_device_profile a where a.deviceid in (select deviceid from o_device_profile where 1=1 GROUP BY deviceid having count(deviceid) > 1);

delete from o_device_profile where deviceid='testmyfoxcameraadd1255' and epid not in (select epid from (select max(epid) epid from o_device_profile where deviceid='testmyfoxcameraadd1255')a);

##########################################################

############# o_service_info 脏数据 ######################
select DISTINCT(deviceid) from o_service_info a where a.deviceid in (select deviceid from o_service_info where `status`='00' GROUP BY deviceid having count(deviceid) > 1) and a.status='00'
         
update o_service_info set `status`='09' where `status`='00' and deviceid=#deviceid# and osid not in (select osid from (select max(osid) osid from o_service_info where `status`='00' and deviceid=#deviceid#) a);

##########################################################

你可能感兴趣的:(清除)