数据库随机一条数据

SELECT
    *
FROM
    `t_ana` AS a
JOIN (
    SELECT
        ROUND(
            RAND() * (
                SELECT
                    MAX(id)
                FROM
                    `t_ana`
            )
        ) AS id
) AS t2
WHERE
    a.id >= t2.id
AND a.`status` = 1
ORDER BY
    a.id ASC
LIMIT 1

你可能感兴趣的:(数据库随机一条数据)