use information_schema;
select table_name,table_rows from tables
where TABLE_SCHEMA = 'test'
order by table_rows desc;
The above is the existing query statement, which can find all the tables in the entire database and how much data is in the table.
Now I want to break it down:
For example, there are 1,000 tables in the test database, and I only want to check 200 of them (specified) Contain the specified date (with the date field, The type is mediumtext) and how many pieces of data there are.
How to write this kind of query statement?
-----------------Modified question----------------------
I can’t express it clearly, so I’ll describe it again:
As shown above, I have many tables in the test database, and each table has a lot of data. Each table has a field "time", the type is mediumtext, such as 2017-5-9 16:44:24.
I want to query multiple tables at one time to see how many pieces of data each table has that contains the specified "time" (2017-5-9).
use information_schema;
select table_name,table_rows from tables
where TABLE_SCHEMA = 'test' and TABLE_NAME in ('Specification 1','Specification 2',.......,'Specification 200') and UPDATE_TIME = 'Specification Time'
order by table_rows desc;
The author is talking about finding the table containing the date field of the specified type, right? information_schema also has a columns table, and you can do a joint query