Please note, this is a STATIC archive of website www.javatpoint.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
Javatpoint Logo
Javatpoint Logo

MariaDB DISTINCT Clause

MariaDB DISTINCT Clause is used to remove duplicates from the result when we use it with SELECT statement.

Syntax:

Note: When you use only expression in DISTINCT clause, the query will return the unique values for that expression.When you use multiple expression in
the DISTINCT clause, the query will return unique combinations for the multiple expressions listed.
The DISTINCT clause doesn't ignore NULL values. So when using the DISTINCT clause in your SQL statement, your result set will include NULL as a distinct value.

Example:


Using Single Expression

We have a table name "Students", having some duplicate entries. A name "Ajeet" is repeated three times.

Mariadb Distinct clause 1

Let's use the DISTINCT clause to remove duplicates from the table.

Output:

Mariadb Distinct clause 2

You can see that "Ajeet" is repeated three times in the original "Students" table but after using DISTINCT clause, it is returned one time and duplicate entries are deleted.


Using Multiple Expressions

You can use DISTINCT clause to remove duplicates from more than one expression in MariaDB.

Output:

Mariadb Distinct clause 3





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA