mysql - Find duplicates in database based on two records -


i have database fields following:

id -- user id -- role id  1  --- 100 ----- 119 2  --- 100 ----- 119 3  --- 101 ----- 101 4  --- 102 ----- 250 5  --- 103 ----- 300 

i'd able feed in list of user ids, , have return role id's duplicated. example, sample above, print out following:

100 --- 119 --- 2 

i'd query able delete these duplicates well, after run select see results

select user_id, role_id, count() user_roles user_id in () group user_id, role_id having count() > 1;


Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -