1.

How can you handle duplicate data points in SQL?

Answer»

We can come across a situation in which we can find MULTIPLE duplicate data entries in a table which makes no sense to fetch all those entries to avoid redundancy while we are fetching records from that table. We need only those unique data entries that will make sense to fetch.

For achieving this, DISTINCT KEYWORD is provided by the SQL which we can use with the SELECT statement so that we can eliminate the duplicate data entries and can only fetch unique data entries.

The syntax to use this keyword to eliminate duplicate data is as below:

SELECT DISTINCT COLUMN1, column2, column3...columnM FROM table_name1 WHERE [conditions]

We can also this use UNIQUE keyword to handle duplicate data. The UNIQUE constraint is used for ENSURING that all the values present in a specific column are different in SQL.



Discussion

No Comment Found