delete FROM `test_table` WHERE id in (SELECT id,concat(user_id,user_id2) as __f
FROM `test_table` where user_id = 11
GROUP BY `__f`
HAVING COUNT( * ) >1) and id not in (SELECT min(id),concat(user_id,user_id2) as __f
FROM `test_table` where user_id = 11
GROUP BY `__f`
HAVING COUNT( * ) >1)

 

select id,user_id from test_table where user_id = 11 and id not in (SELECT id,concat(user_id,user_id2) as __f
FROM `test_table` where user_id = 11
GROUP BY `__f`
HAVING COUNT( * ) >1) __tmp


delete FROM `test_table` WHERE user_id = 11 and id not in (select id from (SELECT id,concat(user_id,user_id2) as __f
FROM `test_table` where user_id = 11
GROUP BY `__f`
HAVING COUNT( * ) >1) __tmp)

相关文章:

  • 2021-12-18
  • 2022-01-13
  • 2022-12-23
  • 2021-06-06
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案