I wanted to select all records with duplicate session numbers (session_number) from my forms table so I’ll know if there are error of duplicate entries. I’m using MySQL Database.
Here’s a solution I found:
-I’m just selecting session_number
-I’m selecting records from forms table.
GROUP BY session_number
-This will group all the session_number.
HAVING COUNT(session_number) > 1
-After grouping the session numbers, we will count records with that group’s session number. If it is greater than 1, it means it has duplicates, so it will be selected.
That’s it! :)