SQL SELECT DISTINCT

Learn how to use SQL SELECT DISTINCT statement with this tutorial. Select unique data from the columns of a table using the SQL SELECT DISTINCT statement.

You just need to specify the column name which contains many same data and you want to fetch only the unique data. A table may contain many duplicate data and to get an accurate result on your application. You need to fetch only the distinct values from the table.

Distinct data are the required and valid data when you want to show only the different values in the drop-down select box. If you want to display your user’s duplicate values in the drop-down, your users may gets confused with your application.

How to Use SQL SELECT DISTINCT Statement to Retrieve Unique Data

Using the DISTINCT clause with the SELECT statement is the simple method. You just need to put the DISTINCT clause after the SELECT statement. Then after you have to specify the column name from which you want to fetch only the distinct values and not the duplicate values.

Syntax

You can specify the condition after the WHERE clause by which you will get the selected data from the table. The description of the parameters is given below.

Parameter Descriptions

Sr.No Parameter Name Description
1 column1, column2…columnN Enter only the required column name here you want to select from the table. You can also use the symbol (*) to select all the columns from a table.
2 tablename Specify the name of the table her from where you want to fetch and select the data.
3 condition Specify the condition of the data which you want to only select and display.

You must also learn.

Reference