Distinct records
-
Hi All, I want to select all fields without duplication of records. Please help me. Jegastar
jegastar wrote:
I want to select all fields without duplication of records
SELECT * FROM MyTable
This will return exactly one instance of each row in the named table. However, if two rows have the exact same column values then you will get two rows back that look the same. Stricktly speaking if this happens then data model is likely wrong because all rows should be distinct.
SELECT DISTINCT * FROM MyTable
This will ensure that if two rows share the same information that only one of them will be returned.
Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos
-
jegastar wrote:
I want to select all fields without duplication of records
SELECT * FROM MyTable
This will return exactly one instance of each row in the named table. However, if two rows have the exact same column values then you will get two rows back that look the same. Stricktly speaking if this happens then data model is likely wrong because all rows should be distinct.
SELECT DISTINCT * FROM MyTable
This will ensure that if two rows share the same information that only one of them will be returned.
Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos