雷达智富

首页 > 内容 > 程序笔记 > 正文

程序笔记

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

2025-01-22 5
查询数据库中所有表名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);更新于:3小时前
赞一波!

文章评论

评论问答