首页 > 代码库 > MySQL 多表查询分页

MySQL 多表查询分页

SELECT
    v.*, vt.id vid,
    vt.vote_id,
    vt. option,
    vt.poll
FROM
    vote v
JOIN vote_option vt ON v.id = vt.vote_id
WHERE
    v.id IN (
        SELECT
            t.id
        FROM
            (
                SELECT
                    id
                FROM
                    vote
                ORDER BY
                    id DESC
                LIMIT 0,
                2
            ) AS t
    )
ORDER BY
    id DESC

 

MySQL 多表查询分页