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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -