开发者

mySQL: Can I make count() honor limit clause?

开发者 https://www.devze.com 2022-12-30 09:14 出处:网络
I\'m trying to get a count of rec开发者_C百科ords matching certain criteria within a subset of the total records. I tried (and assumed this would work)

I'm trying to get a count of rec开发者_C百科ords matching certain criteria within a subset of the total records. I tried (and assumed this would work)

SELECT count(*) 
FROM   records 
WHERE  status = 'ADP'
LIMIT  0,10

and I assumed this would tell me how many records of status ADP were in that set of 10 records. It doesn't - it returns, in this case 30, which is the total number of ADP records in the table.

How do I just count up the records matching my criteria including the limit?


SELECT count(*)  
FROM   ( SELECT records  
          FROM table
          WHERE  status = 'ADP' 
          LIMIT  0,10 
       )


select count(*) from (select * from records where status='ADP' limit 0,10) as t;
0

精彩评论

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