PDA

Click to See Complete Forum and Search --> : Double ups and SQL


CGTS
Jul 27th, 2000, 12:10 AM
Use the DISTINCT or DISTINCTROW command in you SELECT SQL statement.

The DISTINCT clause is used to remove duplicate records from the resulting data set. i.e. "SELECT DISTINCT MyName FROM tblNames"
This will return one entry for each MyName that exists, so if there are two or more "Colin's" in your table it will only show one thus........

MyName MyLastName Age
Colin Green Old
Colin Green Old
Colin Green 35
Peter Paul 41

Will return
MyName
Colin
Peter

The DISTINCTROW clause is used to select data that is distinct in any of the fields. i.e. "SELECT DISTINCTROW * FROM tblNames"
This will return one entry for each non duplicate record that, so if there are two or more "Colin's" in your table it will return any unique records thus.............

MyName MyLastName Age
Colin Green Old
Colin Green 35
Peter Paul 41


Hope this helps!

JHausmann
Jul 27th, 2000, 11:00 AM
Distinctrow is, I believe, a Jet "enhancement" to SQL. You cannot use that keyword in SQL Server 6.5 or Sybase, for example.