How can I get records out in an array, but only once even if there is an duplicate... I want to get a all the courses a golfer has played during a season, but the player might have played the same course several of times, and I only wants to show once which courses he has played. $sql="SELECT * FROM ".$prefix."_played WHERE user='$userid' AND season=1"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $course = $row['courseid']; } PHP: This just loops out each record even if the courseid is the same... Please help...
You could try "select distinct ...." rather than "select ..." in your statement, the distinct keyword makes it so duplicate records are not returned, but I believe that all field results need to be the same in order for it to count as a duplicate....
Thanks, that was what I was looking for, but... I want it to be with an INNER JOIN like this: $sql="SELECT DISTINCT courseid FROM ".$prefix."_stroke INNER JOIN ".$prefix."_courses ON ".$prefix."_stroke.courseid = ".$prefix."_courses.courseid WHERE user='$userid'"; PHP: When I set it up like above I get error, but if I change "SELECT DISTINCT courseid" to "SELECT *" I get no errors but alot of duplicate outputs... How do I use this with "INNER JOIN"? Thanks.