成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

查詢(xún)mysql數(shù)據(jù)庫(kù)中指定表指定日期的數(shù)據(jù)?有詳細(xì)

瀏覽:123日期:2022-06-13 08:38:32

問(wèn)題描述

use information_schema;select table_name,table_rows from tableswhere TABLE_SCHEMA = ’test’order by table_rows desc;

上面是現(xiàn)有的查詢(xún)語(yǔ)句,可以查到整個(gè)數(shù)據(jù)庫(kù)中所有的表以及表里有多少數(shù)據(jù)。現(xiàn)在我想細(xì)分一下:比如test數(shù)據(jù)庫(kù)中有1000張表,我只想查其中的200張(指定的)包含指定日期的(有日期這個(gè)字段,類(lèi)型是mediumtext)有多少條數(shù)據(jù)。請(qǐng)問(wèn)下這種該怎么寫(xiě)查詢(xún)語(yǔ)句?

-----------------修改后的問(wèn)題----------------------是我表述不清,我重新描述下:查詢(xún)mysql數(shù)據(jù)庫(kù)中指定表指定日期的數(shù)據(jù)?有詳細(xì)

如上圖,我在test數(shù)據(jù)庫(kù)有很多張表,每張表里都有很多數(shù)據(jù)。每張表都有一個(gè)字段“時(shí)間”,類(lèi)型是mediumtext,如2017-5-9 16:44:24。我想一次查詢(xún)多張表,每張表分別有多少條包含指定“時(shí)間”(2017-5-9)的數(shù)據(jù)。

問(wèn)題解答

回答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:

樓主說(shuō)的是找到包含指定類(lèi)型的日期字段的表吧?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)文章: