Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query with SQL statement to return Unique records

Status
Not open for further replies.

HebieBug

Programmer
Jan 8, 2001
354
JP
Am creating a connection to an SQL 2000 database.
The reordset is generated with a SQL string.
When I was working with Access forms notied their was an option to display only unique records.
If I had a field with called Example and the records inside where:
John
John
Peter
Peter
Paul
HebieBug
Then the reordset would contain:
John
Peter
Paul
HebieBug
Is there a way of adding to the SQL string a command that will omit duplicate records?

 
Yes,

If you use the word 'DISTINCT' in the sql query, the duplication is omitted. For example:

SELECT DISTINCT * FROM TABLENAME WHERE ....

ok
 
The sql statement should look like:

sql = SELECT DISTINCT FirstName FROM TableName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top