

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the number of rows in a particular table with MySQL
Let us first create a table −
mysql> create table DemoTable -> ( -> LastName varchar(100) -> ); Query OK, 0 rows affected (0.68 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Smith'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Miller'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Taylor'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Brown'); Query OK, 1 row affected (0.29 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+----------+ | LastName | +----------+ | Smith | | Miller | | Taylor | | Brown | +----------+ 4 rows in set (0.00 sec)
Following is the query to get the number of rows in a particular table in the database “web” −
mysql> select table_rows from INFORMATION_SCHEMA.tables -> where table_schema='web' and table_name='DemoTable';
Output
This will produce the following output −
+------------+ | TABLE_ROWS | +------------+ | 4 | +------------+ 1 row in set (0.16 sec)
- Related Questions & Answers
- Easiest way to get number of rows in a MySQL table?
- Get the number of columns in a MySQL table?
- How to get number of rows in a table without using count(*) MySQL query?
- Count number of rows in each table in MySQL?
- Get number of fields in MySQL table?
- In MySQL, how can we get the number code of a particular character?
- How to count number of rows in a table with jQuery?
- Get at least x number of rows in MySQL?
- How to get the values of a particular row in a table in Selenium with python?
- Can we get total number of rows in a MySQL database?
- Create a stored procedure to get the detail of a particular MySQL table stored in a database?
- Fastest way to count number of rows in MySQL table?
- Fetch random rows from a table with MySQL
- How to count the number of rows in a table in Selenium with python?
- Delete only specific rows in a table with MySQL
Advertisements