首頁  >  問答  >  主體

查詢mysql資料庫中指定表格指定日期的資料?有詳細

use information_schema;
select table_name,table_rows from tables
where TABLE_SCHEMA = 'test'
order by table_rows desc;

上面是現有的查詢語句,可以查到整個資料庫中所有的表格以及表格裡有多少資料。
現在我想細分一下:
例如test資料庫中有1000張表,我只想查其中的200張(指定的)包含指定日期的(有日期這個字段,類型是mediumtext)有多少條資料。
請問下這種該怎麼寫查詢語句?

-----------------修改後的問題----------------------
是我表述不清,我重新描述下:

#如上圖,我在test資料庫有很多張表,每張表裡都有許多資料。每張表都有一個字段“時間”,類型是mediumtext,如2017-5-9 16:44:24。
我想一次查詢多張表,每張表分別有多少條包含指定「時間」(2017-5-9)的資料。

PHP中文网PHP中文网2710 天前970

全部回覆(2)我來回復

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-18 10:51:37

    use information_schema;
    從表中選擇table_name,table_rows
    where TABLE_SCHEMA = 'test' and TABLE_NAME in ('Specification 1','Specification 2',.......,'Specification 200') and UPDATE_TI'Specification 2',.......,'Specification 200') and UPDATE_TI'Specification 2',.......,'Specification 200') and UPDATE_TI'Specification 2',.......,'Specification 200') and UPDATE_TI'Specification 2',.......,'Specification 200') and UPDATE_TI'Specification = '規範時間'
    order by table_rows desc;

    回覆
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-18 10:51:37

    樓主說的是找到包含指定類型的日期欄位的表格吧? 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_schema
    where a.TABLE_SCHEMA = 'test' and b.DATA_TYPE='mediumtext' and COLUMN_NAME='指定日期字段'
    order by table_rows desc;

    回覆
    0
  • 取消回覆