[thelist] MySql Select Problem

rudy r937 at interlog.com
Tue Apr 9 21:00:00 CDT 2002


> SELECT sportName,sportCaptain,captainPhone
>      FROM sports
>   WHERE venueName ='".$venueName."'";
>
> The primary key in the sports table is sportName
> and venueName is a foreign key.

hi bill

so far so good, although foreign keys are not usually full names like your
example (DC Convention Center), rather they are typically short
identifiers, where the identifier is a key to another table (venue) which
holds the name

> My problem is this: when the results of the query are printed
> out I get the correct number of sports per venue, but the first
> name is repeated. For example, the venue DC Convention Center
> has Badminton,Triathlon,Swimming and Soccer for sports but
> Badminton  gets printed out 4 times.  Any ideas what this could be?

bad programming?

i don't know php but presumably there's some sort of looping, and you are
probably outputting the wrong field

martin, regarding your comment...

> [I'm not sure if you can add more comma-seperated field names
> after the DISTINCT sportName clause]

... yes you can, but i don't think that's his problem


rudy




More information about the thelist mailing list