MySQL + SQL · Lesson 45
SELECT DISTINCT in MySQL
SELECT DISTINCT
DISTINCT removes duplicate values from the result, showing each unique value only once.
SELECT DISTINCT class FROM students;If many students share a class, each class name appears once.
DISTINCT on Multiple Columns
SELECT DISTINCT class, section FROM students;Returns unique class+section combinations.
Summary
- DISTINCT shows unique values only.
- With multiple columns, the whole combination must be unique.
💻 Live Code Editor
This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.