SELECT COUNT(ID) AS RANK1 FROM `db_ranking` WHERE `sid`=2 AND `rank`=1
UNION
SELECT COUNT(ID) AS RANK2 FROM `db_ranking` WHERE `sid`=2 AND `rank`=2
UNION
SELECT COUNT(ID) AS RANK3 FROM `db_ranking` WHERE `sid`=2 AND `rank`=3
UNION
SELECT COUNT(ID) AS RANK4 FROM `db_ranking` WHERE `sid`=2 AND `rank`=4
UNION
SELECT COUNT(ID) AS RANK5 FROM `db_ranking` WHERE `sid`=2 AND `rank`=5
我想在列中显示每个 SELECT 结果。
所以我想要 5 列,每列都有一个 ID 计数..
所以应该是这样的
RANK1 RANK2 RANK3 RANK4 RANK5
0 3 5 6 7
我现在不明白..我不知道为什么