Helo,我有mysql的问题!如何查询一次以在一个查询中获取这两个信息?
SELECT * FROM PVP_stats
WHERE UUID = '4c5be598-11e7-480a-a255-483473b2a452'
LIMIT 1;
SELECT COUNT(id) FROM PVP_stats
WHERE Elo >= (SELECT Elo FROM PVP_stats
WHERE UUID = "4c5be598-11e7-480a-a255-483473b2a452");
答案 0 :(得分:0)
首先,您可以使用相关子查询
来合并第二个查询中的计数SELECT *,
(SELECT COUNT(id) FROM PVP_stats WHERE Elo >= s.Elo ) `count`
FROM PVP_stats s
WHERE s.UUID = '4c5be598-11e7-480a-a255-483473b2a452'
LIMIT 1;