mysql - How can I filter a table with duplicate entries to display the rows that exist the most? -
i hope question makes sense.. have table called genre_tags contains music_id , genre_id column
it can contain duplicate entries
music_id | genre_id 281 3 281 3 281 4 243 7 90 6 90 6 90 10
what want retrieve duplicate entries based on genre_id
so based on example above left result
music_id | genre_id 281 3 243 7 90 6
try this,
select music_id, genre_id tablename group music_id, genre_id having count(*) = (select count(*) total tablename b a.music_id = b.music_id group music_id, genre_id order total desc limit 1)
Comments
Post a Comment