Reputation: 1272
i have schema like this http://sqlfiddle.com/#!17/30859/1, as you can see in that SQL fiddle i have query that i need to improve, actually i need to add new column that will give me total number of participants in each tournament, i'm not sure how i can do that, i tried sub select but without any success. Thanks in advance for help
Upvotes: 2
Views: 51
Reputation: 5952
SELECT t.id, t.name as tournamentName, m.name as creator, s.name as
sponsorName,
(count * from member_tournament mt where mt.tournament_id=t.id) members
FROM tournament t
LEFT JOIN member m ON m.id = t.member_id
LEFT JOIN sponsor s ON s.id = t.sponsor_id
Upvotes: 1