©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The FOUND_ROWS SQL Function in MySQL and MariaDB - Number of rows after SELECT

FOUND_ROWSSyntax:FOUND_ROWS()
Return value:INTEGER
Function type:Information function
Function Description

The FOUND_ROWS() function returns either the number of rows from a result of a SELECT statement, or the number of possible rows using the SELECT option SQL_CALC_FOUND_ROWS if the SELECT statement without LIMIT clause would be executed.

The FOUND_ROWS() function also works with other statements that return result sets, including SHOW, DESC and HELP.

Statements without result sets do not affect FOUND_ROWS(). The previous value is then returned. If there is no previous value, 0 is returned.

After a CALL statement, this function returns the number of rows selected by the last query in the procedure.

SQL Examples for the FOUND_ROWS function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14

select found_rows();

select `Name`,`css`,`link`,`typ` from `asysfonts` limit 10;
select found_rows();

select SQL_CALC_FOUND_ROWS `Name`,`css`,`link`,`typ` from `asysfonts` limit 10;
select found_rows();
select count(*) from `asysfonts`;


show charset;
select found_rows();

found_rows()
bigint(21)
0
Name
css
link
typ
varchar(50) LATIN1varchar(255) LATIN1varchar(50) LATIN1varchar(20) LATIN1
ArialArial sans-serif
Helvetica"Helvetica Neue" sans-serif
VerdanaVerdana, Geneva, sans-serif sans-serif
Times New Roman"Times", Times, san-serif sans-serif
Courier (Monospace)Courier, monospace monospace
Lucida Console (Monospace)"Lucida Console", Courier, monospace monospace
Cursivecursive handwriting
Fantasyfantasy  
Goudy Bookletter 1911"Goudy Bookletter 1911", sans-serif sans-serif
Gill Sans ExtraboldGill Sans Extrabold, sans-serif sans-serif
found_rows()
bigint(21)
10
Name
css
link
typ
varchar(50) LATIN1varchar(255) LATIN1varchar(50) LATIN1varchar(20) LATIN1
ArialArial sans-serif
Helvetica"Helvetica Neue" sans-serif
VerdanaVerdana, Geneva, sans-serif sans-serif
Times New Roman"Times", Times, san-serif sans-serif
Courier (Monospace)Courier, monospace monospace
Lucida Console (Monospace)"Lucida Console", Courier, monospace monospace
Cursivecursive handwriting
Fantasyfantasy  
Goudy Bookletter 1911"Goudy Bookletter 1911", sans-serif sans-serif
Gill Sans ExtraboldGill Sans Extrabold, sans-serif sans-serif
found_rows()
bigint(21)
847
count(*)
bigint(21)
847
Charset
Description
Default collation
Maxlen
information_schema.CHARACTER_SETS
CHARACTER_SET_NAME
varchar(32) UTF8
information_schema.CHARACTER_SETS
DESCRIPTION
varchar(60) UTF8
information_schema.CHARACTER_SETS
DEFAULT_COLLATE_NAME
varchar(32) UTF8
information_schema.CHARACTER_SETS
MAXLEN
bigint(3)
big5Big5 Traditional Chinesebig5_chinese_ci2
dec8DEC West Europeandec8_swedish_ci1
cp850DOS West Europeancp850_general_ci1
hp8HP West Europeanhp8_english_ci1
koi8rKOI8-R Relcom Russiankoi8r_general_ci1
latin1cp1252 West Europeanlatin1_swedish_ci1
latin2ISO 8859-2 Central Europeanlatin2_general_ci1
swe77bit Swedishswe7_swedish_ci1
asciiUS ASCIIascii_general_ci1
ujisEUC-JP Japaneseujis_japanese_ci3
sjisShift-JIS Japanesesjis_japanese_ci2
hebrewISO 8859-8 Hebrewhebrew_general_ci1
tis620TIS620 Thaitis620_thai_ci1
euckrEUC-KR Koreaneuckr_korean_ci2
koi8uKOI8-U Ukrainiankoi8u_general_ci1
gb2312GB2312 Simplified Chinesegb2312_chinese_ci2
greekISO 8859-7 Greekgreek_general_ci1
cp1250Windows Central Europeancp1250_general_ci1
gbkGBK Simplified Chinesegbk_chinese_ci2
latin5ISO 8859-9 Turkishlatin5_turkish_ci1
armscii8ARMSCII-8 Armenianarmscii8_general_ci1
utf8UTF-8 Unicodeutf8_general_ci3
ucs2UCS-2 Unicodeucs2_general_ci2
cp866DOS Russiancp866_general_ci1
keybcs2DOS Kamenicky Czech-Slovakkeybcs2_general_ci1
macceMac Central Europeanmacce_general_ci1
macromanMac West Europeanmacroman_general_ci1
cp852DOS Central Europeancp852_general_ci1
latin7ISO 8859-13 Balticlatin7_general_ci1
utf8mb4UTF-8 Unicodeutf8mb4_general_ci4
cp1251Windows Cyrilliccp1251_general_ci1
utf16UTF-16 Unicodeutf16_general_ci4
utf16leUTF-16LE Unicodeutf16le_general_ci4
cp1256Windows Arabiccp1256_general_ci1
cp1257Windows Balticcp1257_general_ci1
utf32UTF-32 Unicodeutf32_general_ci4
binaryBinary pseudo charsetbinary1
geostd8GEOSTD8 Georgiangeostd8_general_ci1
cp932SJIS for Windows Japanesecp932_japanese_ci2
eucjpmsUJIS for Windows Japaneseeucjpms_japanese_ci3
found_rows()
bigint(21)
40
The examples were created with the MyWAY SQL manager: Download

How to use the FOUND_ROWS() function in MySQL and MariaDB databases

In MySQL and MariaDB the FOUND_ROWS() function is used to count the number of result rows of a SQL Query to retrieve, or the number of result rows that would be returned by a SELECT query without the LIMIT clause. This can also be used to determine the total number of result rows that match a given condition, even if the original query uses the LIMIT clause to limit the number of rows returned. The function requires no arguments and is usually called immediately after executing a SELECT query, or a SELECT query using the LIMIT clause used with SQL_CALC_FOUND_ROWS option.

Using SQL_CALC_FOUND_ROWS and FOUND_ROWS() together can have an impact on performance, especially with large tables, because the database first must calculate the total number of matching rows before applying the LIMIT clause.

Further MySQL und MariaDB SQL Information functions

BENCHMARKBENCHMARK(Number, Expression)
More about BENCHMARK Function

BINLOG_GTID_POSBINLOG_GTID_POS()

CHARSETCHARSET(String)
More about CHARSET Function

COERCIBILITYCOERCIBILITY(String)
More about COERCIBILITY Function

COLLATIONCOLLATION(String)
More about COLLATION Function

CONNECTION_IDCONNECTION_ID()
More about CONNECTION_ID Function

CURRENT_USERCURRENT_USER()
More about CURRENT_USER Function

CURRENT_ROLECURRENT_ROLE()
More about CURRENT_ROLE Function

DATABASEDATABASE()
More about DATABASE Function

DECODE_HISTOGRAMDECODE_HISTOGRAM()

DEFAULTDEFAULT(Column)
More about DEFAULT Function

LAST_INSERT_IDLAST_INSERT_ID([Expression])
More about LAST_INSERT_ID Function

LAST_VALUELAST_VALUE(Expression [, Expression ...])
More about LAST_VALUE Function

ROWNUMROWNUM()

ROW_COUNTROW_COUNT()
More about ROW_COUNT Function

SCHEMASCHEMA()
More about SCHEMA Function

SESSION_USERSESSION_USER()
More about SESSION_USER Function

SYSTEM_USERSYSTEM_USER()
More about SYSTEM_USER Function

USERUSER()
More about USER Function

VERSIONVERSION()
More about VERSION Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the FOUND_ROWS SQL function: mysql.com and mariadb.com
Updated: 2023-09-17ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2023 Heino Cunze-Fischer