Eliminating Duplicate Rows with DISTINCT
Columns often contain duplicate values, and it’s common to want a result that lists each duplicate only once. If I type Listing 4.6 to list the states where the authors live, the result, Figure 4.6, contains unneeded duplicates. The DISTINCT keyword eliminates duplicate rows from a result.
Listing 4.6. List the states in which the authors live. See Figure 4.6 for the result.
Figure 4.6. Result of Listing 4.6. This result contains unneeded duplicates of CA and NY.
To eliminate duplicate rows:
columns is one or more comma-separated column names, and table is the name of the table that contains ...
SELECT DISTINCT columns