开发者

Get count of all results with LIMIT in the query

开发者 https://www.devze.com 2023-04-12 06:27 出处:网络
SELECT `p`.`name`, `f`.* FROM `players` `p`, `folks` `f` WHERE `p`.`id` = `f`.`guid` AND `f`.`deleted` = 0
SELECT `p`.`name`, `f`.*
        FROM `players` `p`, `folks` `f`
        WHERE `p`.`id` = `f`.`guid` 
        AND `f`.`deleted` = 0
        AN开发者_开发技巧D `first` = {$id} 
        AND `text` LIKE ?
        LIMIT 10

As you can see I'm using a LIMIT condition here. I need to count all results that will be matched without LIMIT cond.

I've tried using: FOUND_ROWS(); but I got problems with using it, as it doesn't return 'all' results anywhere.


The following should do :) Important is the SQL_CALC_FOUND_ROWS, otherwise FOUND_ROWS() won't work!

SELECT SQL_CALC_FOUND_ROWS `p`.`name`, `f`.*
    FROM `players` `p`, `folks` `f`
    WHERE `p`.`id` = `f`.`guid` 
    AND `f`.`deleted` = 0
    AND `first` = {$id} 
    AND `text` LIKE ?
    LIMIT 10


SELECT FOUND_ROWS();
0

精彩评论

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