SQL SELECT DISTINCT বিন্যাস
- Previous Page SQL select
- Next Page SQL where
This chapter explains the SELECT DISTINCT statement.
SQL SELECT DISTINCT বিন্যাস
In a table, there may be duplicate values. This is not a problem, but sometimes you may want to list only different (distinct) values.
The keyword DISTINCT is used to return unique values.
Syntax:
SELECT DISTINCT column_name FROM table_name
Using DISTINCT Keyword
If we want to select all values from the 'Company' column, we need to use the SELECT statement:
SELECT Company FROM Orders
"Orders" Table:
Company | OrderNumber |
---|---|
IBM | 3532 |
W3School | 2356 |
Apple | 4698 |
W3School | 6953 |
Result:
Company |
---|
IBM |
W3School |
Apple |
W3School |
Please note that CodeW3C.com is listed twice in the result set.
To select only unique values from the 'Company' column, we need to use the SELECT DISTINCT statement:
SELECT DISTINCT Company FROM Orders
Result:
Company |
---|
IBM |
W3School |
Apple |
Now, 'W3School' is listed only once in the result set.
- Previous Page SQL select
- Next Page SQL where