SQL query to get duplicate value
To get duplicate values from a table in SQL, you can use the GROUP BY
clause with the HAVING
clause. Here’s an example SQL query that retrieves duplicate values from a table named tbl_app_users
:
SELECT email, COUNT(*) c FROM tbl_app_users GROUP BY email HAVING c > 1
Replace column_name
with the name of the column that you want to check for duplicates. This SQL query groups the rows by the specified column and counts the number of occurrences of each value. The HAVING
clause filters the results to show only the values that have more than one occurrence, indicating that they are duplicates.
You can modify this SQL query to suit your needs by changing the table name, column name, and any additional conditions that you want to apply.