mysql查询当天时间段的sql语句怎么写呢

mysql查询当天时间段的sql语句怎么写呢,第1张

你的问题描述的不够明确,不太清楚你要的效果,这样,给你两种效果:

1、显示某个时间段的数据:

select * from tb where hour(col_datetime)=18 and to_days(col_datetime)=to_days(curdate())

2、按时间段排序,显示当天所有时间段数据:

select '今天'+cast(hour(col_datetime) as varchar(2))+'时发布的内容',* from tb where to_days(col_datetime)=to_days(curdate()) order by col_datetime

查看SQL执行时间步骤

1.show profiles

2.show variables查看profiling 是否是on状态;

3.如果是off,则执行命令 set profiling=1

4.执行SQL语句

5.show profiles 就可以查询到SQL语句的执行时间


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6105133.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-14
下一篇 2023-03-14

发表评论

登录后才能评论

评论列表(0条)

保存