Forum Moderators: coopster

Message Too Old, No Replies

Finding duplicate entries and listing one of each

Finding duplicate entries and listing one of each

         

drooh

5:53 pm on Dec 24, 2007 (gmt 0)

10+ Year Member



I have a mysql database with scheduled classes for a fitness program. There is a field for location.

I would like to query the database to extract a list of the locations and only one of each location.

Then after getting this list I would like to query the same db again for results pertaining to just that location.

So something like this

$sql = "Get List of Locations"
$sql = "Show just one of each"

any help would be super, cheers

eelixduppy

6:18 pm on Dec 24, 2007 (gmt 0)



You could do a query similar to this one that might get you what you want:

$query = "SELECT DISTINCT `location` FROM `table_name`";

You can refer to mysql's SELECT syntax [dev.mysql.com] for more information on distinct.