Removing repeats with DISTINCT
List each value only once.
SELECT DISTINCT removes duplicate rows from the result. SELECT genre FROM books shows a genre once per book, so Fiction appears three times. SELECT DISTINCT genre FROM books shows each genre once. It is handy for questions like "which cities do our members live in?"
SELECT DISTINCT city FROM members;Eight members, but only three different cities: Riverside, Hillview and Lakeside.
DISTINCT applies to the whole row, not just the first column. SELECT DISTINCT city, name FROM members keeps every member, because each city-and-name pair is different.