开发者

MySQL returns some rows 3 times AGAIN

开发者 https://www.devze.com 2023-02-12 09:24 出处:网络
Still returns the same results! Got rid of divs. Now the query is: SELECT w.windate, w.wintime, w.field,

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 li开发者_JAVA技巧st of scheduled games that I want to display for a given coach.


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'
0

精彩评论

暂无评论...
验证码 换一张
取 消