查出来的列表添加序号

SELECT
            @rownum := @rownum + 1 AS serialNum,obj.*
        FROM
            (
                SELECT
                    z.id AS "id",
                    z. NAME AS "name",
                    ifnull(e.score, 0) AS "score",
                    z.photo AS "photo"
                FROM
                    z_user z
                LEFT JOIN exchange.e_score e ON e.user_id = z.id
            where
                    z.Status = 1
                                ORDER BY
                    e.score DESC
            ) AS obj,
            (SELECT @rownum := 0) r

你可能感兴趣的:(Mysql)