Home All Groups Group Topic Archive Search About

Deleting duplicate values in a DataSet

Author
20 Apr 2006 3:04 PM
glenn
Hi folks,

I have a DataSet that returns values from a single column in a database
where I query a table named USERS for companies that are working on a given
project.

The SQL statement is as follows:

SELECT COMPANYNAMES FROM USERS WHERE PROJECT = @PROJECT

In many cases I have users who are from the same company working on the same
project.  I have considered my database design but I don't see that it needs
changes or how to query it to not receive duplicate values.

For example values such as MICROSOFT, ORACLE, MICROSOFT would need to have
duplicate values to be MICROSOFT, ORACLE.

I have checked the DataSet methods but none exist to handle this.
Thanks for any thoughts.
glenn

Author
20 Apr 2006 3:21 PM
Kerry Moorman
Glenn,

You could get distinct values from the database:

SELECT DISTINCT COMPANYNAMES FROM USERS WHERE PROJECT = @PROJECT

Kerry Moorman


Show quote
"glenn" wrote:

> Hi folks,
>
> I have a DataSet that returns values from a single column in a database
> where I query a table named USERS for companies that are working on a given
> project.
>
> The SQL statement is as follows:
>
> SELECT COMPANYNAMES FROM USERS WHERE PROJECT = @PROJECT
>
> In many cases I have users who are from the same company working on the same
> project.  I have considered my database design but I don't see that it needs
> changes or how to query it to not receive duplicate values.
>
> For example values such as MICROSOFT, ORACLE, MICROSOFT would need to have
> duplicate values to be MICROSOFT, ORACLE.
>
> I have checked the DataSet methods but none exist to handle this.
> Thanks for any thoughts.
> glenn
Author
20 Apr 2006 3:33 PM
glenn
Kerry,

Thanks so much for your help.  SELECT DISTINCT solved my problem.

I looked through my SQL statement reference and there it was - DISTINCT.

Just haven't had the need to use it - until now.

Thanks again,
Glenn

Show quote
"Kerry Moorman" wrote:

> Glenn,
>
> You could get distinct values from the database:
>
> SELECT DISTINCT COMPANYNAMES FROM USERS WHERE PROJECT = @PROJECT
>
> Kerry Moorman
>
>
> "glenn" wrote:
>
> > Hi folks,
> >
> > I have a DataSet that returns values from a single column in a database
> > where I query a table named USERS for companies that are working on a given
> > project.
> >
> > The SQL statement is as follows:
> >
> > SELECT COMPANYNAMES FROM USERS WHERE PROJECT = @PROJECT
> >
> > In many cases I have users who are from the same company working on the same
> > project.  I have considered my database design but I don't see that it needs
> > changes or how to query it to not receive duplicate values.
> >
> > For example values such as MICROSOFT, ORACLE, MICROSOFT would need to have
> > duplicate values to be MICROSOFT, ORACLE.
> >
> > I have checked the DataSet methods but none exist to handle this.
> > Thanks for any thoughts.
> > glenn

AddThis Social Bookmark Button