查询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. sublime-text - sublime text 3中编译python(sublimeREPL),如何仅运行单行/选定部分2. python3.x - python多进程,不能在同一窗口吗3. 网页爬虫 - python爬虫用BeautifulSoup爬取<s>元素并写入字典,但某些div下没有这一元素,导致自动写入下一条,如何解决?4. mysql按照时间热度排序5. android-studio - android app微信登录一定要申请了登录权限才能测试?6. javascript - html5多个label中其中一个触发change,如何判断是哪一个出发了change7. 使用weex扩展html5的项目存在ios不同版本的兼容性8. pdo_mysql 值自增写法9. mysql - phpMyAdmin无法导入数据10. 导入数据库不成功

网公网安备