如果不使用LIMIT,使用COUNT()和FOUND_ROWS()有什么区别? [英] What is the difference of using COUNT() and FOUND_ROWS() if I don't use a LIMIT?

查看:128
本文介绍了如果不使用LIMIT,使用COUNT()和FOUND_ROWS()有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用之间有区别

SELECT COUNT()

反对

SELECT FOUND_ROWS()

我知道发现有限制时应该使用行,但是如果不使用限制,真的有区别吗?

I know found rows is supposed to be used when you have a limit but if you don't use a limit is there really any difference?

推荐答案

您将获得相同的结果,但是有两种不同的方式.

You will get the same result but in two different ways.

COUNT()是聚合函数在选择和分组数据时使用.

COUNT() is an aggregated function used when selecting and grouping data.

FOUND_ROWS()是信息功能 之后另一个选择以获取有关发生的情况的信息.

FOUND_ROWS() is a information function used after another select to get information on what happened.

如果只需要将行数与COUNT()一起使用,则速度更快.

If you only need the number of rows go with COUNT(), it's faster.

赞:

select count(*) as number_of_rows from some_table where something = something group by something;

select * from some_table where something = something group by something;
select found_rows();

这篇关于如果不使用LIMIT,使用COUNT()和FOUND_ROWS()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆