Sql Select Distinct
An sql select distinct statement returns a set of different data records from one or more data tables.
Distinct means different.
In this sql select distinct tutorial we will use the sample table below for our sql select distinct statement examples.
Users Table; tbl_users
| id | Name | Password | Age | |
|---|---|---|---|---|
| 1 | John Doe | johndoe@j.com | e56Hdf-2 | 34 |
| 2 | Jane Doe | janedoe@j.com | p59Hdf-2 | 32 |
| 2 | Gary Doe | garydoe@j.com | y02Tdf-2 | 23 |
| 1 | John Doe | johndoe@j.com | e86756Hdf-2 | 44 |
| 2 | Jane Doe | janedoe@j.com | p8759Hdf-2 | 19 |
SQL Select Distinct Code
SELECT DISTINCT Name FROM tbl_users
This sql query will return only the distinct different rows from users table.
The result
| Name |
|---|
| John Doe |
| Jane Doe |
| Gary Doe |