查詢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ù)。請問下這種該怎么寫查詢語句?
-----------------修改后的問題----------------------是我表述不清,我重新描述下:
如上圖,我在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. node.js - mongodb查找子對象的名稱為某個(gè)值的對象的方法2. html5 - datatables 加載不出來數(shù)據(jù)。3. 運(yùn)行python程序時(shí)出現(xiàn)“應(yīng)用程序發(fā)生異常”的內(nèi)存錯(cuò)誤?4. docker 下面創(chuàng)建的IMAGE 他們的 ID 一樣?這個(gè)是怎么回事????5. 利用IPMI遠(yuǎn)程安裝centos報(bào)錯(cuò)!6. 前端 - @media query 使用出現(xiàn)的問題?7. javascript - 在 model里定義的 引用表模型時(shí),model為undefined。8. 測試自動(dòng)化html元素選擇器元素ID或DataAttribute [關(guān)閉]9. javascript - QQ第三方登錄的問題10. html5和Flash對抗是什么情況?

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