Ignoring Duplicate Rows

# Fetch only unique last names from a # phone book SELECT DISTINCT surnames FROM phonebook; 

Some queries might return duplicate rows of data. This might happen when selecting just the last names of people listed in a phone book. If you used a simple query of

SELECT surnames FROM phonebook; 

you would likely have thousands of duplicated rows for common names such as Moore, Johnston, and Smith.

If you place the DISTINCT clause after the SELECT, multiple values are returned only once.

When the query selects more than one column, DISTINCT only removes duplicate rows where every column value is identical.

MySQL Phrasebook. Essential Code and Commands
MySQL Phrasebook
ISBN: 0672328399
EAN: 2147483647
Year: 2003
Pages: 130

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net