【问题标题】:Why Limit keyword is not working in Mysql?为什么限制关键字在 Mysql 中不起作用?
【发布时间】:2017-06-25 14:25:24
【问题描述】:

select count(*) from bill limit 100000;

mysql> select count(*) from `bill` limit 100000; +----------+ | count(*) | +----------+ | 47497305 | +----------+ 1 row in set

【问题讨论】:

  • 看这个stackoverflow.com/questions/36174805/…>

标签: mysql


【解决方案1】:

limit 限制结果集中输出的行数,而不是处理的行数。

因此它对count(*) 之类的查询没有任何影响。

要实现这一点,您必须将查询包装到另一个子选择中。虽然这样的查询没有太大意义:

SELECT COUNT(*) FROM (
    SELECT * FROM bill LIMIT 100000
) t

【讨论】:

    猜你喜欢
    • 2012-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-26
    • 2012-07-03
    • 1970-01-01
    • 2020-12-08
    • 1970-01-01
    相关资源
    最近更新 更多