我有兩個我想合併爲一個的查詢。將兩個查詢合併爲一個
第一個看起來像這樣;
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'
第二個看起來像這樣;
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')
我懷疑JOIN會成爲解決方案的一部分,我只是不知道如何。 任何想法讚賞。
偉大的想法,謝謝! –