douguai4653 2011-02-22 15:44
浏览 12

MySQL返回3次AGAIN的行数

Still returns the same results! Got rid of divs. Now the query is:

SELECT w.windate,
       w.wintime,
       w.field,
       w.htname,
       w.vtname,
       w.plateumpire,
       w.fieldumpire1,
       w.fieldumpire2,
       w.fieldumpire3,
       p.pteamname,
       p.teamcoach
FROM playerteams AS p 
  INNER JOIN sportsdb_wins AS w ON p.pteamname IN (w.htname,w.vtname)
WHERE p.teamcoach = '$coachid'
AND   p.forteam = '$teamid'

but no joy!

I am trying to display a list of teams that all have the same p.teamcoach. The playerteams table contains each team and has teamcoach set to that coach. sportsdb_wins contains a list of scheduled games that I want to display for a given coach.

  • 写回答

1条回答 默认 最新

  • dongmi8980 2011-02-22 16:00
    关注

    How are you associating team coaches to teams. I would suggest you have a table for coaches and foreign key this to the playerteams table. That way your coaches are only entered once. Something like...

    SELECT w.windate,
    w.wintime,
    w.field,
    w.htname,
    w.vtname,
    w.plateumpire,
    p.pteamname,
    pc.coach_name
    FROM player_coaches AS pc
    INNER JOIN playerteams AS p
    ON p.coachId = pc.coachId
    INNER JOIN sportsdb_wins AS w
    ON p.pteamname IN (w.htname, w.vtname)
    WHERE p.coachId = '$coachId'
    AND p.forteam = '$teamId'
    
    评论

报告相同问题?