mysql查本月数据
时间: 2023-10-26 11:56:41 浏览: 127
要查询 MySQL 中本月的数据,可以使用以下 SQL 语句之一:
1. 使用 YEAR() 和 MONTH() 函数:
SELECT column1, column2, ...
FROM table_name
WHERE YEAR(date_column) = YEAR(CURRENT_DATE()) AND MONTH(date_column) = MONTH(CURRENT_DATE());
\[1\]
2. 使用 DATE_FORMAT() 函数:
SELECT *
FROM table_name
WHERE DATE_FORMAT(date_column, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m');
\[2\]
以上两种方法都可以查询到本月的数据。你可以根据自己的需求选择其中一种方法来使用。
#### 引用[.reference_title]
- *1* [MySQL查询本月数据](https://blog.csdn.net/db_dc_dmc/article/details/131123405)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Mysql查询当天,本周,本月所有数据记录](https://blog.csdn.net/weixin_44167913/article/details/94436378)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [MySQL查询今天、昨天、本月、上月等数据](https://blog.csdn.net/qq_43428376/article/details/109514186)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文