Count from a table, but stop counting at a certain number

前端 未结 3 1726
别跟我提以往
别跟我提以往 2021-01-18 08:13

Is there a way in MySQL to COUNT(*) from a table where if the number is greater than x, it will stop counting there? Basically, I only want to know

3条回答
  •  清酒与你
    2021-01-18 08:59

    This works:

    select count(*) from ( select * from  stockinfo s limit 100 ) s
    

    but was not any faster (that I could tell) from just:

    select count(*) from stockinfo
    

    which returned 5170965.

提交回复
热议问题