Filling form select with non-duplicate data.

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
User avatar
Etherguy
Forum Commoner
Posts: 70
Joined: Fri Nov 01, 2002 9:09 pm
Location: Long Island, New York

Filling form select with non-duplicate data.

Post by Etherguy »

Okay, if I got you this far by just the subject I must be going down the right path :)

Here is my problem, I have a mysql database with about 33,000 records or so. In field "a" there is a list of names full of duplicates ( which is fine ). What I would like to do is display the list of names in a drop down form, but want the names to only show up once not a million times.

Example : Lets say I have a name Robert Smith in field "a", the name Robet Smith is listed 20 times in that field because he put out 20 hits or what ever. Now I want to allow a user to select Robert Smith from a drop down form so that we can refine the search to just hits by just him.

I know how to produce the select form from the database, but can't seem to get it to display just once. Any help would be greatly appreciated.

Regards
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

SELECT DISTINCT(column_name) FROM table

that should do it. im a little shaky on the syntax but im pretty shure thats right.
DynamiteHost
Forum Commoner
Posts: 69
Joined: Sat Aug 10, 2002 5:33 pm

Post by DynamiteHost »

mydimension, i find that doesnt work...

but i find this does:

SELECT DISTINCT column_name FROM table
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

yeah, i thought the syntax was a little off. thx for the correction.
DynamiteHost
Forum Commoner
Posts: 69
Joined: Sat Aug 10, 2002 5:33 pm

Post by DynamiteHost »

np :)
Post Reply