bug_x

导航

 


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)

posted on 2017-12-07 15:57  bug_x  阅读(1283)  评论(0编辑  收藏  举报