C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
SQL DELETE DUPLICATE ROWSIf you have got a situation that you have multiple duplicate records in a table, so at the time of fetching records from the table you should be more careful. You make sure that you are fetching unique records instead of fetching duplicate records. To overcome with this problem we use DISTINCT keyword. It is used along with SELECT statement to eliminate all duplicate records and fetching only unique records. SYNTAX: The basic syntax to eliminate duplicate records from a table is: SELECT DISTINCT column1, column2,....columnN FROM table _name WHERE [conditions] EXAMPLE: Let us take an example of STUDENT table.
Firstly we should check the SELECT query and see how it returns the duplicate percentage records. SQL > SELECT PERCENTAGE FROM STUDENTS ORDER BY PERCENTAGE;
Now let us use SELECT query with DISTINCT keyword and see the result. This will eliminate the duplicate entry. SQL > SELECT DISTINCT PERCENTAGE FROM STUDENTS ORDER BY PERCENTAGE;
Next TopicSQL Delete Database
|