Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have Three tables as,

Player Table,

- id
- name
- team_id

Team Table:

- id
- image
- tournament_id

Tournaments Table:

- id
- name

and I want to fetch count of employee appearing in Tournaments. Thanks

question from:https://stackoverflow.com/questions/65931323/how-to-fetch-player-record-from-table-in-sql

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
131 views
Welcome To Ask or Share your Answers For Others

1 Answer

I want to fetch count of employee appearing in Tournaments.

This can be achieved using JOIN and group by as follows:

select t.id, t.name, count(*)
  from tournaments t
  join team tm on t.id = tm.tournament_id
  join player p on p.team_id = tm.id
 group by t.id, t.name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...