查詢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. android - 用textview顯示html時如何寫imagegetter獲取網絡圖片2. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能3. showpassword里的this 是什么意思?代表哪個元素4. javascript - windows下如何使用babel,遇到了困惑5. JavaScript事件6. python - 為什么正常輸出中文沒有亂碼,zip函數之后出現中文編程unicode編碼的問題,我是遍歷輸出的啊。7. javascript - js中向下取整8. android - rxjava多線程并發怎么控制順序9. 對mysql某個字段監控的功能10. html - vue項目中用到了elementUI問題
