DISTINCT Operator
DISTINCT removes duplicate values from results.
Syntax
sql
1SELECT DISTINCT column FROM table;Example: Unique Courses
sql
1SELECT DISTINCT course FROM students;Result
| course |
|---|
| Python |
| JavaScript |
| Ruby |
| HTML |
Without DISTINCT
sql
1SELECT course FROM students;
2-- Returns duplicates: Python, Python, JavaScript, Python...Multiple Columns
sql
1SELECT DISTINCT course, grade FROM students;Returns unique combinations.
