查詢mysql數(shù)據(jù)庫中指定表指定日期的數(shù)據(jù)?有詳細(xì)
問題描述
use information_schema;select table_name,table_rows from tableswhere TABLE_SCHEMA = ’test’order by table_rows desc;
上面是現(xiàn)有的查詢語句,可以查到整個(gè)數(shù)據(jù)庫中所有的表以及表里有多少數(shù)據(jù)。現(xiàn)在我想細(xì)分一下:比如test數(shù)據(jù)庫中有1000張表,我只想查其中的200張(指定的)包含指定日期的(有日期這個(gè)字段,類型是mediumtext)有多少條數(shù)據(jù)。請(qǐng)問下這種該怎么寫查詢語句?
-----------------修改后的問題----------------------是我表述不清,我重新描述下:
如上圖,我在test數(shù)據(jù)庫有很多張表,每張表里都有很多數(shù)據(jù)。每張表都有一個(gè)字段“時(shí)間”,類型是mediumtext,如2017-5-9 16:44:24。我想一次查詢多張表,每張表分別有多少條包含指定“時(shí)間”(2017-5-9)的數(shù)據(jù)。
問題解答
回答1:use information_schema;select table_name,table_rows from tableswhere TABLE_SCHEMA = ’test’ and TABLE_NAME in (’指定1’,’指定2’,.......,’指定200’) and UPDATE_TIME = ’指定時(shí)間’order by table_rows desc;
回答2:樓主說的是找到包含指定類型的日期字段的表吧?information_schema還有一個(gè)columns表,聯(lián)查就有了
select a.table_name,a.table_rows from tables a join columns b on a.table_name=b.table_name and a.table_schema=b.table_schemawhere a.TABLE_SCHEMA = ’test’ and b.DATA_TYPE=’mediumtext’ and COLUMN_NAME=’指定日期字段’order by table_rows desc;
相關(guān)文章:
1. docker-compose中volumes的問題2. boot2docker無法啟動(dòng)3. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””4. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.5. java - SSH框架中寫分頁時(shí)service層中不能注入分頁類6. nignx - docker內(nèi)nginx 80端口被占用7. dockerfile - 為什么docker容器啟動(dòng)不了?8. 關(guān)于docker下的nginx壓力測(cè)試9. node.js - antdesign怎么集合react-redux對(duì)input控件進(jìn)行初始化賦值10. docker容器呢SSH為什么連不通呢?

網(wǎng)公網(wǎng)安備