DISTINCT

Remove duplicate rows from the result, so each value or combination appears once.

Syntax

SELECT DISTINCT column_list FROM table_name;

Example

SELECT DISTINCT city FROM customers ORDER BY city;

Each city with at least one customer, once, in alphabetical order.

Tables used: customers. Try it in a lesson below.

Common mistakes

  • DISTINCT applies to the whole row. Adding a column can make more rows appear, not fewer.

Practise it