MySQL Distinct Clause

By: Prem Tiwari | Last Updated: | In: MySQL Tutorial

MySQL DISTINCT clause is used in MySQL queries to filter the data after removing the duplicate records. By using DISTINCT clause, you will fetch only the unique records from the database table. In this tutorial, I will share MySQL Distinct clause with examples.

MySQL Distinct Clause

Below is the syntax of writing MySQL DISTINCT clause in your MySQL queries.

Example 1

Below query will fetch the unique records from the employee table basis on employee name.

Example 2

Another example with two fields to fetch records from the table.

Example 3

A distinct clause with WHERE statement.