Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Fuzzy query method of SQL time Type

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "SQL time type fuzzy query method", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's train of thought slowly in depth, together to study and learn "SQL time type fuzzy query method" bar!

Today, use the time Like '2008-06-01%' statement to query all the data of that day, and you are prompted with a statement error. After checking it, it is found that the fuzzy query can only be used for fields of type String. I have also consulted some materials myself. There are three ways to make fuzzy queries about time:

Convert is converted to String, which is queried with Like. Select * from table1 where convert (varchar,date,120) like '2006-04-01%'

Between select * from table1 where time between '2006-4-1 015 and' 2006-4-1 2415 59 and'"

Datediff () function select * from table1 where datediff (day,time,'2006-4-1') = 0 the first method should apply to any data type; the second method should apply to types other than String

The third method is a more practical and quick method customized for the date type.

Thank you for your reading, the above is the content of "fuzzy query method of SQL time type". After the study of this article, I believe you have a deeper understanding of the fuzzy query method of SQL time type, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report