SQLite DISTINCT Clause

The SQLite DISTINCT clause is used with SELECT statement to eliminate all the duplicate records and fetching only unique records.

It is used when you have multiple duplicate records in the table.

Syntax:

snippet
SELECT DISTINCT column1, column2,.....columnN 
FROM table_name
WHERE [condition]

Example:

We have a table named "STUDENT", having the following data:

Sqlite Distinct clause 1

First Select NAME from "STUDENT" without using DISTINCT keyword. It will show the duplicate records:

snippet
SELECT NAME FROM STUDENT ;

Output:

Sqlite Distinct clause 3

Now, select NAME from "STUDENT" using DISTINCT keyword.

snippet
SELECT DISTINCT NAME FROM STUDENT;

Output:

Sqlite Distinct clause 3
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +