In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces mysql how to query the year's data related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this mysql how to query the data of the year, let's take a look.
In mysql, you can use the "DATE_SUB ()" function to query the data for a year, which is used to set the specified time interval subtracted from the date. The syntax is "SELECT * FROM table name WHERE time field > DATE_SUB (data, INTERVAL 1 YEAR)".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How does mysql query the data for a year?
The DATE_SUB () function subtracts the specified interval from the date.
Grammar
DATE_SUB (date,INTERVAL expr type)
The date parameter is a valid date expression. The expr parameter is the interval you want to add.
Examples are as follows:
SELECT * FROM table name WHERE time field > DATE_SUB (CURDATE (), INTERVAL 1 YEAR) one year SELECT * FROM table name WHERE time field > DATE_SUB (CURDATE (), INTERVAL 1 WEEK) one week SELECT * FROM table name WHERE time field > DATE_SUB (CURDATE (), INTERVAL 3 MONTH) three months
Expand knowledge:
Suppose we have the following "Orders" table:
Now, we want to subtract five days from "OrderDate".
We use the following SELECT statement:
SELECT OrderId,DATE_SUB (OrderDate,INTERVAL 5 DAY) AS SubtractDateFROM Orders
Results:
This is the end of the article on "how to query the data of the year by mysql". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to query the data of mysql for a year". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.