SQLite – DISTINCT Keyword




SQLite – DISTINCT Keyword

SQLite – DISTINCT Keyword

 

DISTINCT is a optional keyword in SQLite indicating that the answer should not contain duplicates..

In SQLite, the default is that duplicates are not eliminated! (Result is called a “multiset”).

There can be situations where multiple duplicates entries are present in table records.
DISTINCT keyword helps us to fetch the unique values from the database

Syntax:

If DISTINCT specified then duplicate rows from the result set will be eliminated.

Example:

So let’s consider we have created SCHOOL database. And we have created a STUDENTS table in this database.

The STUDENTS table have five columns (ID, NAME, SURNAME, AGE, ADDRESS).

The STUDENTS table also have some data inside it as shown below:


First we will see the result of normal select query.

The result of above query is shown below:

Now we will use DISTINCT keyword with the select query.

The result of above query is shown below:

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com