mysql 根据日期时间查询数据
mysql> select * from table1;
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 1hahha | 1xiaohong | | -- :: |
| 2hahha | 2xiaohong | | -- :: |
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
| 3hahha | lee | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.01 sec) mysql> select * from table1 where minute(order_date)=;
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
| 3hahha | lee | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.00 sec) mysql> select * from table1 where second(order_date) between and ;
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
| 3hahha | lee | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.00 sec) mysql> select * from table1 where second(order_date) between and ;
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.00 sec)
mysql> select * from table1;
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 1hahha | 1xiaohong | | -- :: |
| 2hahha | 2xiaohong | | -- :: |
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
| 3hahha | lee | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.01 sec) mysql> select * from table1 where date(order_date)='2019-08-04';
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 1hahha | 1xiaohong | | -- :: |
| 2hahha | 2xiaohong | | -- :: |
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
| 3hahha | lee | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.00 sec) mysql> select * from table1 where date(order_date) between '2019-08-04' and '2019-08-04';
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 1hahha | 1xiaohong | | -- :: |
| 2hahha | 2xiaohong | | -- :: |
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
| 3hahha | lee | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.00 sec) mysql> select * from table1 where order_date between '2019-08-04 20:45:47' and '2019-08-04 20:46:08';
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 1hahha | 1xiaohong | | -- :: |
| 2hahha | 2xiaohong | | -- :: |
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.00 sec) mysql> select * from table1 where time(order_date) between '20:45:47' and '20:46:08';
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 1hahha | 1xiaohong | | -- :: |
| 2hahha | 2xiaohong | | -- :: |
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.00 sec) mysql> select * from table1 where time(order_date)='20:46:02';
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 3hahha | 3xiaohong | | -- :: |
+----------+------------+-----+---------------------+
row in set (0.00 sec)
mysql> select * from table1 where time(order_date) between "20:45:47" and "20:46:08";
+----------+------------+-----+---------------------+
| name_new | transactor | pid | order_date |
+----------+------------+-----+---------------------+
| 1hahha | 1xiaohong | | -- :: |
| 2hahha | 2xiaohong | | -- :: |
| 3hahha | 3xiaohong | | -- :: |
| 4hahha | 4xiaohong | | -- :: |
| 3hahha | bob | | -- :: |
+----------+------------+-----+---------------------+
rows in set (0.00 sec)
mysql 根据日期时间查询数据的更多相关文章
- mysql 根据日期进行查询数据,没有数据也要显示空
写这篇博客主要是记录自己在对订单进行按日期查询时使用的一种查询的方法,这里的orders是订单表,你也可以改成别的什么表对于最终数据不会造成影响,除非你那个表的数据只有几条那样就会出现查不到日期的情况 ...
- MySql 按日期条件查询数据
本周内: select * from wap_content where week(created_at) = week(now) 查询一天: select * from table where to ...
- 在数据库中(Oracle),根据时间查询数据: to_date()和to_char()函数
1. to_date() 函数 1.1 格式 to_date("要转换的字符串","转换的格式") //两个参数的格式必须匹配,否则会报错.即按照第二个参数 ...
- MySQL数据类型--日期时间
一.博客前言 自接触学习MySQL已有一段时间了,对于MySQL的基础知识还是略懂略懂的.在这一路学习过来,每次不管看书还是网上看的资料,对于MySQL数据类型中的时间日期类型总是一扫而过,不曾停下来 ...
- MySQL 按照日期格式查询带有时间戳数据
按照日期格式查询带有时间戳数据一般在MSQL数据库中的时间都是以时间戳的格式来存储时间的,但是对于我们来说,时间戳格式具体表示的是什么时间,我们很难一眼看出来,所以当我们要具体查询某一个时间或时间段的 ...
- MySQL之日期时间类型
mysql(5.5)所支持的日期时间类型有:DATETIME. TIMESTAMP.DATE.TIME.YEAR. 几种类型比较如下: 日期时间类型 占用空间 日期格式 最小值 最大值 零值表示 D ...
- MySQL常用日期时间函数
日期和时间函数: MySQL服务器中的三种时区设置: ①系统时区---保存在系统变量system_time_zone ②服务器时区---保存在全局系统变量global.time_zone ③每个客户端 ...
- MySQL之日期时间函数
1.NOW() 用法:显示当前日期和时间 举例: mysql> select NOW(); +---------------------+ | NOW() | +-------------- ...
- 4、MySQL 申明变量给查询数据编号
摘自: https://www.cnblogs.com/qixuejia/archive/2010/12/21/1913203.html https://blog.csdn.net/arbben/ar ...
随机推荐
- WebRTC 入门教程(二)| WebRTC信令控制与STUN/TURN服务器搭建
WebRTC 入门教程(二)| WebRTC信令控制与STUN/TURN服务器搭建 四月 4, 2019 作者:李超,音视频技术专家.本文首发于 RTC 开发者社区,欢迎在社区留言与作者交流. htt ...
- mysql-数据备份与存储过程
目录 修改隔离级别 存储过程 什么是存储过程 用来干什么 三种数据处理方式 备份与恢复 修改隔离级别 修改全局的 set global transaction isolation level read ...
- Java自学-控制流程 break
Java的break语句 结束循环 示例 1 : break; 直接结束当前for循环 public class HelloWorld { public static void main(String ...
- 30个关于Shell脚本的经典案例(中)
本文目录 11.iptables自动屏蔽访问网站频繁的IP 12.判断用户输入的是否为IP地址 13.判断用户输入的是否为数字 14.给定目录找出包含关键字的文件 15.监控目录,将新创建的文件名追加 ...
- streamController
- head 与 tail
head head [-n] 数字『文件』 显示前面n行 例如 head -n 3 test 显示 test 文件的前 3 行,也可以写作 head -3 test 比较有趣的是 -n 后面的数字,可 ...
- 突然用xcode老版本调试老代码测试新机,报错"Could not find Developer Disk Image"回忆下
转载:https://www.cnblogs.com/blogwithstudyofwyn/p/6003176.html 说明:更新了手机的到了iOS 10.0.2.真机调试时候提示"Cou ...
- PcAnywhere用法
安装软件 配置被控端 点击"主机",点击"添加" 可以使用"现有的Windows账户",也可以创建新的"用户名和密码" ...
- React: webpack模块组织关系
现代前端开发离不开打包工具,以 webpack 为代表的打包工具已经成为日常开发必备之利器,拿 React 技术栈为例,我们 ES6 形式的源代码,需要经过 webpack 和 Babel 处理,才能 ...
- Spring— 用更优雅的方式发HTTP请求(RestTemplate详解)
RestTemplate是Spring提供的用于访问Rest服务的客户端,RestTemplate提供了多种便捷访问远程Http服务的方法,能够大大提高客户端的编写效率. 我之前的HTTP开发是用ap ...