多字段查询重复的语句
其中
a.historyHumi, a.historyTemp, a.historyTime, a.historyIndex
是需要使用的字段
SELECT*FROM MGWeatherglassValueTable a
WHERE
(SELECT count(1) FROM MGWeatherglassValueTable WHERE a.historyTime=historyTime AND a.historyIndex=historyIndex AND a.historyHumi=historyHumi AND a.historyTemp=historyTemp)> 1
删除重复的数据只保存一条重复的数据
delete from MGWeatherglassValueTable
where keyId not
in ( select * from(select keyId from MGWeatherglassValueTable group by historyHumi,historyTemp, historyTime, historyIndex) b);
网友评论