SQL SELECT DISTINCT STATEMENT
SQL DISTINCT STATEMENT:
This statement is use to select the distinct value or different value from the database.
In a Table, the column can contain or have same value(duplicate), so to get the unique value or different value we use distinct statement.
SYNTAX:
SELECT DISTINCT Column1, Column2... FROM Table_Name;
SELECT DISTINCT Column1, Column2... FROM Table_Name;
DATABASE TABLE
Item Table
|
Itemcode |
Itemname |
Price |
|
4001 |
Pen |
50 |
|
4002 |
Pen |
20 |
|
4003 |
notebook |
40 |
EXAMPLE:
SELECT DISTINCT itemname from item;
The OUTPUT for the above code:
|
Itemname |
|
Pen |
|
notebook |