SQL DISTINCT

It returns the DISTINCT values  from a table.

SQL DISTINCT Syntax

SELECT DISTINCT(column_name) FROM table_name

MySQL Table – users

+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | JS   |
|  3 | HTML |
|  4 | PHP  |
+—-+——+

Example

mysql> select distinct(name) from users ;
+——+
| name |
+——+
| PHP  |
| JS   |
| HTML |
+——+
3 rows in set (0.00 sec)

Share