我有这个sql从players
记录集中获取单个玩家的财富排名(位置)。但我需要加入users
表,以便在找到位置时忽略被禁止的玩家。
我现有的代码(检查玩家ID 5):
SELECT z.rank FROM
(SELECT p.id, p.name, @rownum := @rownum + 1 AS rank FROM players p, (SELECT @rownum := 0) r
WHERE p.this != 'that' ORDER BY p.cash + p.bank DESC) as z #
WHERE id=5;
所以我需要的是这样的东西:(这不起作用)
SELECT z.rank FROM
(SELECT p.id, p.name,
(SELECT ban FROM u.users WHERE id=p.account_id) as banned, @rownum := @rownum + 1 AS rank FROM players p, (SELECT @rownum := 0) r
WHERE p.this != 'that' AND banned=0 ORDER BY p.cash + p.bank DESC) as z #
WHERE id=5;
对我来说太复杂了!