How To Use Distinct Keyword In SQL

Introduction

In this article, we will learn how to use the DISTINCT keyword with a SQL select query.

Inside a table, a column may contain many duplicate values; To select only different (distinct) values from a database in SQL SELECT DISTINCT statement is used.

Syntax

SELECT DISTINCT column1, column2, ...columnN
FROM TABLE_NAME;

Example

The subsequent statement would return only the DISTINCT values from the Title field in the Article table.

SELECT DISTINCT Title FROM Article;

 

Also, check How To Write Select Query In SQL

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories