Counting the number of rows in a table using mysql

What is the syntax in getting the total number of rows in a particular table in a mysql database?

+3
source share
4 answers

I always did

SELECT count(*) from table

Above all, you give the total number of all rows.

You can just as easily apply the WHERE clause to get a count of some subset

SELECT count(*) from table WHERE foo = 'bar'
+11
source
SELECT count(*)
FROM table_name
+3
source

COUNT (*) :

MYTH: " InnoDB count (*)":

count (*) , WHERE, InnoDB .

: InnoDB count (*) where

+2

It depends on the involvement of the storage mechanism. Basically, from a SQL perspective, the same thing, but performance may vary. I found this blog post helpful: http://www.dbasquare.com/2012/04/02/can-count-be-used-in-mysql-on-innodb-tables/

0
source

Source: https://habr.com/ru/post/1704030/


All Articles