1

我希望限制父级(文章)给出的行数,你知道怎么做吗?我不想限制总行数(LIMIT x),只限制“文章”表中的行数。

SELECT * FROM articles
INNER JOIN categories
ON articles.category_id = categories.id
INNER JOIN articleInfo
ON articles.id = articleInfo.article_id
INNER JOIN articleWeights
ON articles.id = articleWeights.article_id
INNER JOIN articlePictures
ON articles.id = articlePictures.article_id
WHERE articleInfo.lang = :lang

很无奈,怎么也找不到。。

谢谢!

4

1 回答 1

1

既然你提到LIMIT了,我假设你正在使用MySQL. 您可以LIMIT使用subquery

SELECT * 
FROM (SELECT * FROM articles LIMIT 10) articles
    INNER JOIN categories
        ON articles.category_id = categories.id
    INNER JOIN articleInfo
        ON articles.id = articleInfo.article_id
    INNER JOIN articleWeights
        ON articles.id = articleWeights.article_id
    INNER JOIN articlePictures
        ON articles.id = articlePictures.article_id
WHERE articleInfo.lang = :lang
于 2013-10-16T05:10:18.553 回答