MySQL SQLLesson 6Free preview
MySQL SELECT DISTINCT
This lesson is part of MySQL · All levels
Summary
The SELECT DISTINCT command is used when you want results without duplicate values on selected columns. MySQL compares the value combinations on all the columns mentioned, so one row is considered duplicate only if the entire option column is the same. This feature is useful for finding out unique values such as a list of customer cities or the type of product that has ever been sold.
Key points
- DISTINCT removes a row where the entire column of choice is equal to the value
- The DISTINCT clause is placed right after SELECT
- DISTINCT works on a combination of columns, not per column separately
- DISTINCT is different from the primary key which guarantees the uniqueness of stored data
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.