If you want the query to return only unique rows, use the keyword DISTINCT after SELECT . DISTINCT can be used to fetch unique rows from one or more columns. You need to list the columns after the DISTINCT keyword.
How do I not allow duplicate rows in SQL?
The SQL DISTINCT keyword, which we have already discussed is used in conjunction with the SELECT statement to eliminate all the duplicate records and by fetching only the unique records.
How do I restrict duplicate entries in database?
You can prevent data duplicates in a database by creating a unique index. The unique index will demand that each data in the indexed field is unique in value and properties. You can create a new index by setting up a data-definition query that creates a new index. This can be done using SQL view.