Mysql是否具有与mssql中的@@ ROWCOUNT等效的功能? [英] Does Mysql have an equivalent to @@ROWCOUNT like in mssql?
本文介绍了Mysql是否具有与mssql中的@@ ROWCOUNT等效的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何像@@ROWCOUNT
在mssql中那样在MySQL中获取行计数值?
How can I get row count values in MySQL as @@ROWCOUNT
does in mssql?
推荐答案
For SELECTs you can use the FOUND_ROWS
construct (documented here):
SELECT SQL_CALC_FOUND_ROWS something FROM your_table WHERE whatever;
SELECT FOUND_ROWS( ) ;
将返回上一个SELECT
查询中的行数(或者,如果第一个查询具有LIMIT
子句,它将返回没有LIMIT
时的行数).
which will return the number of rows in the last SELECT
query (or if the first query has a LIMIT
clause, it returns the number of rows there would've been without the LIMIT
).
对于UPDATE
/DELETE
/INSERT
,它是这将返回受影响的行数.
which will return the number of affected rows.
这篇关于Mysql是否具有与mssql中的@@ ROWCOUNT等效的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文