开发者

SQL Join With Limit Range

I'm trying to add a limit range to my sql join statement so I can do pagination of my records, but when I enter in the limit range to my statement I'm getting nothing returned. With the limit range taken out it all works fine.

Here is what I have:

$sql= "SELECT R.id,companyName,membershipID,addressID,city,logo,descriptionShort FROM yt_Business_RegInfo R
    INNER JOIN yt_Business_Seasons S
    ON R.id = S.busID AND S.deleted = '0'
    INNER JOIN yt_Business_Address A
    ON R.addressID = A.id
    INNER JOIN yt_Business_Membership M
    ON R.membershipID = M.id AND M.approved = 1
开发者_开发知识库    WHERE R.deleted = '0'
    ORDER BY R.companyName ASC LIMIT $start, $limit";

Any suggestions would be appreciated. Thanks.


That should be:

LIMIT $start, $howMany

If ($howMany <= 0) or ($start > number of rows returned without LIMIT) , then you get 0 results.


Echo the query:

echo $sql;

And check the values of $start and $limit that goes into it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜