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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -