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 ...
随机推荐
- 2019 竞技世界java面试笔试题 (含面试题解析)
本人3年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.竞技世界等公司offer,岗位是Java后端开发,最终选择去了竞技世界. 面试了很多家公司,感觉大部分公司考察的点 ...
- 4_PHP流程控制语句_1_条件控制语句
以下为学习孔祥盛主编的<PHP编程基础与实例教程>(第二版)所做的笔记. PHP流程控制共有3种类型:条件控制结构.循环结构以及程序跳转和终止语句. 4.1 条件控制语句 4.1.1 if ...
- Java知识回顾 (16)常用操作的Java示例
环境设置 Java 实例 – 如何编译一个Java 文件? Java 实例 – Java 如何运行一个编译过的类文件? Java 实例 - 如何执行指定class文件目录(classpath)? Ja ...
- JQuey中ready()的4种写法
在jQuery中,对于ready()方法,共有4种写法: (1)写法一: $(document).ready(functin(){ //代码部分 }) 分析:这种代码形式是最常见的,其中$(docum ...
- Vue.js的路由之——vue-router快速入门
直接先上效果图 这个单页面应用有两个路径:/home和/about,与这两个路径对应的是两个组件Home和About. 整个实现过程 JavaScript 创建组件:创建单页面应用需要渲染的组件 创建 ...
- day 26作业
作业 1.整理TCP三次握手.四次挥手图 三次握手 起初A和B都处于CLOSED状态--B创建TCB,处于LISTEN状态,等待A请求--A创建TCB,发送连接请求(SYN=1,seq=x),进入SY ...
- Ubuntu16.04 网络配置
Ubuntu 网络配置 安装Ubuntu操作系统之后,为了通过Xshell连接主机,或者连接其他主机.需要进行如下网络配置和ssh服务配置. 1 网络配置 1.1 修改网络配置信息 sudo vi / ...
- StringUtils系列之StringUtils.isNotBlank()和StringUtils.isNotBlank()的区别
/** 1. * StringUtils.isNotBlank(); * 判断参数是否不为空. * 1.如果不为空返回true. * 2.如果为空返回false. * StringUtils.isNo ...
- AM335X有关MMC的启动参数问题分析
AM335X有关MMC的启动参数问题分析 一. 问题来源 硬件平台:AM335X芯片 SDK版本:ti-processor-sdk-linux-am335x-evm-03.00.00.04-Linux ...
- Linux CentOS 7 安装PostgreSQL 9.5.17 (源码编译)
近日需要将PostgreSQL数据库从Windows中迁移到Linux中,Linux CentOS 7 安装PostgreSQL 9.5.17 安装过程 特此记录. 安装环境: 数据库:Postgre ...