查詢mysql數據庫中指定表指定日期的數據?有詳細
問題描述
use information_schema;select table_name,table_rows from tableswhere TABLE_SCHEMA = ’test’order by table_rows desc;
上面是現有的查詢語句,可以查到整個數據庫中所有的表以及表里有多少數據。現在我想細分一下:比如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. docker不顯示端口映射呢?2. nignx - docker內nginx 80端口被占用3. fragment - android webView 返回后怎么禁止重新渲染?4. php - mysql 模糊搜索問題5. docker網絡端口映射,沒有方便點的操作方法么?6. docker綁定了nginx端口 外部訪問不到7. angular.js - angular內容過長展開收起效果8. php - 第三方支付平臺在很短時間內多次異步通知,訂單多次確認收款9. thinkphp5.1學習時遇到session問題10. dockerfile - 我用docker build的時候出現下邊問題 麻煩幫我看一下
