Learn MySQL for Developing Web Application

Learn to build web applications with PHP and MySQL, Start your own blog, e-commerce site. In this tutorial you will learn queries of MySQL and MySQLi.

SQL DISTINCT Keyword


The SQL DISTINCT keyword is used in conjunction with the SELECT statement to eliminate all the duplicate records and fetching only unique records.

There may be a situation when you have multiple duplicate records in a table. While fetching such records, it makes more sense to fetch only those unique records instead of fetching duplicate records.

Syntax

The basic syntax of DISTINCT keyword to eliminate the duplicate records is as follows −

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