How to select from multiple rows, and exclude repeats?

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
bironeb
Forum Commoner
Posts: 59
Joined: Thu Nov 20, 2003 12:02 pm

How to select from multiple rows, and exclude repeats?

Post by bironeb »

Im trying to Select from multiple rows in my MySql database and return the results but exclude repeats, then place these results as option values in a select dropdown menu in a forum.

Does anyone have an Idea how I can write the select statement?
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

look here for some drop down ideas:

viewtopic.php?t=22329

and try this for a query

Code: Select all

SELECT DISTINCT column1, column2
FROM tablename
WHERE column1 = 'criteria'
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

Post by kevin7 »

SELECT * FROM TABLE GROUP BY "colmn"

hmm... i think it's worki too...
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

they keyword is DISTINCT - if you include in your SQL-statement like magicrobotmonkey has shown, you only get unique results.
Post Reply