我是靠谱客的博主 直率牛排,这篇文章主要介绍mySQL数据库中关于时间的模糊操作,现在分享给大家,希望可以做个参考。

Mysql模糊查询有以下三种方法:

1.Convert转成日期时间型,在用Like查询。
select * from table1 where convert(date,DATETIME) like ‘2006-04-01%’
第一种方法应该适用与任何数据类型;

2.Betwee
select * from table1 where time between ‘2018-08-01 0:00:00’ and ‘2018-08-01 24:59:59’";
第二种方法适用String外的类型;

3 datediff()函数
select * from table1 where datediff(create_time,‘2018-08-01’)=0

4:选择某月
declare @date int
set @datestart=convert(int,month(dateadd(mm,-1,getdate())))
print @date

原文链接:https://blog.csdn.net/baidu_41660182/article/details/81365448

最后

以上就是直率牛排最近收集整理的关于mySQL数据库中关于时间的模糊操作的全部内容,更多相关mySQL数据库中关于时间内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(116)

评论列表共有 0 条评论

立即
投稿
返回
顶部