mysql:
update table set deleted = 1 where (column1,column2,column3)
in
(select t1.column1,t1.column2,t1.column3 from (select column1,column2,column3 from table group by column1,column2,column3 having count(*) > 1) t1)
and id not in
(select t2.minid from (select min(id) minid from table group by column1,column2,column3 having count(*) > 1) t2)
扩展 : java8 list根据多属性去重,时间类型可以直接转换:
List<User> collectList = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(u -> u.getName() + ";" + u.getAge() + ";" + DateFormatUtils.format(u.getCreateTime(), "yyyy-MM-dd")))), ArrayList::new));