- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check an empty table already in a MySQL database?
To check an empty table is in a database, you need to extract some records from the table. If the table is not empty then the table records would be returned.
Let us first create a table −
mysql> create table DemoTable(Id int,Name varchar(100),Age int); Query OK, 0 rows affected (0.80 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(1001,'John',23); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(1002,'Chris',21); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(1003,'David',22); Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+-------+------+ | Id | Name | Age | +------+-------+------+ | 1001 | John | 23 | | 1002 | Chris | 21 | | 1003 | David | 22 | +------+-------+------+ 3 rows in set (0.00 sec)
Let us delete all records from the table −
mysql> delete from DemoTable where Id IN(1001,1002,1003); Query OK, 3 rows affected (0.19 sec)
Now try to get records from the table on the basis of where condition −
mysql> select Id from DemoTable where Name="John"; Empty set (0.00 sec)
You can see above, since the table is now empty, therefore an empty set is returned.
- How to check if a table already exists in the database with MySQL with INFORMATION_SCHEMA.TABLES.?
- How to insert auto_increment in an already created table in MySQL?
- How to add a column using MySQL SELECT in an already created table?
- Check how many rows are in a MySQL database table?
- How to create and fill a new column in an already created MySQL table?
- MySQL query to check if database is empty or not?
- How to check table status of the tables in a particular MySQL database?
- How to check if a table exists in MySQL and create if it does not already exist?
- Inserting data into a new column of an already existing table in MySQL?
- Select words from a text already in a MySQL table
- How to alter the database engine of a MySQL database table?
- How can we create a table from an existing MySQL table in the database?
- Check if a table is empty or not in MySQL using EXISTS
- Create a MySQL table from already created table selecting specific rows?
- How to check if a MySQL database exists?