I have two queries that I would like to have merged into one.
The first one looks like this;
SELECT t.name,
t.score,
COUNT(m.user_id) AS memberCount
FROM team AS t, team_member AS m
WHERE t.team_id = '$id' AND m.team_id = '$id'
the second one looks like this;
SELECT COUNT(t.team_id) AS rank
FROM team AS t
WHERE t.score > (SELECT t.score
FROM team AS t
WHERE t.team_id = '$id')
I suspect a JOIN would be part of the solution here, I just dont know how.
Any ideas appreciated.
you may, e.g., insert your second query right to SELECT clause of first one: