Mysql查询的一些操作(查表名,查字段名,查当月,查一周,查当天)

本文总结了使用SQL进行数据查询的多种技巧,包括如何查询数据库中所有表名、特定表的所有字段名,以及按日、周、月筛选记录的方法。通过这些技巧,读者可以更高效地管理和分析数据库中的数据。
查询数据库中所有表名
select table_name from information_schema.tables where table_schema='tools' and table_type='base table';
查询指定数据库中指定表的所有字段名column_name

select column_name from information_schema.columns where table_schema='tools' and table_name='content_noteinfo'

select * from wap_content where week(created_at) = week(now)
如果你要严格要求是某一年的,那可以这样
查询一天:
select * from table where to_days(column_time) = to_days(now());
select * from table where date(column_time) = curdate();
查询一周:
select * from table  where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(column_time);
查询一个月:
select * from table  where DATE_SUB(CURDATE(), INTERVAL INTERVAL 1 MONTH) <= date(column_time);
 

转载于:https://www.cnblogs.com/benpao/p/10771211.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值