A Gentle Introduction to

SQL

NEW.

These questions have been submitted by users.



What is the syntax for eliminating duplicate records in a table?

Short answer

SELECT DISTINCT * FROM tableName

Long Answer

You should never have duplicate records in a table. Tables should always have a primary key specified - this will prevent duplicates.

It is impossible to delete duplicate records because we cannot distinguish between the two copies - however we can produce a copy of the table without duplicates. We can then delete everything the original table then copy the data back.

postgres variations:
None

access
db2
mysql
oracle
postgres
sqlserver