Unique select

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

Unique select

Post by someberry »

I know this is possible; I remember seeing it, but can't remember where.

I would like to search a database, but only return 1 of each unique value. For instace, if the database looks like this:

1 cat
2 dog
3 dog
4 dog
5 cat
6 foo

How could I get the SELECT statement to only return:

1 cat
2 dog
3 foo

Thank you,
Someberry.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post by dreamline »

Translated that would be:
select distinct <name of field> from <database> [where clause]

:D
Post Reply