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)