查詢mysql數據庫中指定表指定日期的數據?有詳細
問題描述
use information_schema;select table_name,table_rows from tableswhere TABLE_SCHEMA = ’test’order by table_rows desc;
上面是現有的查詢語句,可以查到整個數據庫中所有的表以及表里有多少數據?,F在我想細分一下:比如test數據庫中有1000張表,我只想查其中的200張(指定的)包含指定日期的(有日期這個字段,類型是mediumtext)有多少條數據。請問下這種該怎么寫查詢語句?
-----------------修改后的問題----------------------是我表述不清,我重新描述下:
如上圖,我在test數據庫有很多張表,每張表里都有很多數據。每張表都有一個字段“時間”,類型是mediumtext,如2017-5-9 16:44:24。我想一次查詢多張表,每張表分別有多少條包含指定“時間”(2017-5-9)的數據。
問題解答
回答1:use information_schema;select table_name,table_rows from tableswhere TABLE_SCHEMA = ’test’ and TABLE_NAME in (’指定1’,’指定2’,.......,’指定200’) and UPDATE_TIME = ’指定時間’order by table_rows desc;
回答2:樓主說的是找到包含指定類型的日期字段的表吧?information_schema還有一個columns表,聯查就有了
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;
相關文章:
1. MySQL數據庫中文亂碼的原因2. dockerfile - 我用docker build的時候出現下邊問題 麻煩幫我看一下3. angular.js - 關于$apply()4. 如何解決Centos下Docker服務啟動無響應,且輸入docker命令無響應?5. nignx - docker內nginx 80端口被占用6. mysql - 新浪微博中的關注功能是如何設計表結構的?7. dockerfile - [docker build image失敗- npm install]9. css - C#與java開發Windows程序哪個好?10. angular.js使用$resource服務把數據存入mongodb的問題。
