Jump to content


Photo

Recalling unique field entries from MySQL


  • Please log in to reply
2 replies to this topic

#1 neo926

neo926
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 12 March 2006 - 05:32 PM

Okay, I don't know the proper way to query my db, and I'm not adept enough to find what I'm looking for in the MySQL Manual.

So, I have a table that contains all my data for various sports columns that have been written. I have fields for author, sport, title, content, and date submitted.

What I would like is to be able to query the db in a way so that it can recall the different sports that have been written about, but I don't want the same sport repeated. For example, let's say that there are currently 7 columns in the db, and if I were to recall the sports field on each column I would get the following list:

football
baseball
football
soccer
hockey
hockey
basketball

I want to be able to query the db and have it give me the following list instead:

football
baseball
soccer
hockey

That way any duplicate entries aren't produced. Thanks in advance for any help.

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 12 March 2006 - 07:10 PM

Try using DISTINCT, e.g.

SELECT DISTINCT sport FROM articles


#3 neo926

neo926
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 12 March 2006 - 08:45 PM

Great, thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users