MySQL 5.6 date 与 string 的转换和比较
字符串的比较比日期更高效。
The following rules describe how conversion occurs for comparison operations:
- If one or both arguments are NULL, the result of the comparison is NULL, except for the NULL-safe <=> equality comparison operator. For NULL <=> NULL, the result is true. No conversion is needed.
- If both arguments in a comparison operation are strings, they are compared as strings.
- If both arguments are integers, they are compared as integers.
- Hexadecimal values are treated as binary strings if not compared to a number.
- If one of the arguments is a TIMESTAMP or DATETIME column and the other argument is a constant, the constant is converted to a timestamp before the comparison is performed. This is done to be more ODBC-friendly. This is not done for the arguments to IN(). To be safe, always use complete datetime, date, or time strings when doing comparisons. For example, to achieve best results when using BETWEEN with date or time values, use CAST() to explicitly convert the values to the desired data type.
A single-row subquery from a table or tables is not considered a constant. For example, if a subquery returns an integer to be compared to a DATETIME value, the comparison is done as two integers. The integer is not converted to a temporal value. To compare the operands as DATETIME values, use CAST() to explicitly convert the subquery value to DATETIME.- If one of the arguments is a decimal value, comparison depends on the other argument. The arguments are compared as decimal values if the other argument is a decimal or integer value, or as floating-point values if the other argument is a floating-point value.
- In all other cases, the arguments are compared as floating-point (real) numbers.
MySQL 5.6 date 与 string 的转换和比较的更多相关文章
- mybatis与mysql中的Date和String之间转换
在javaweb开发过程中,难免会使用日期类型,在持久化时java的日期格式可以是String,Date.mysql格式可以是varchar,datetime.他们之间如何进行相互转化? 1 java ...
- Java Date,long,String 日期转换
1.java.util.Date类型转换成long类型java.util.Date dt = new Date();System.out.println(dt.toString()); //java. ...
- MySQL5.6中date和string的转换和比较
Conversion & Comparison, involving strings and dates in MySQL 5.6 我们有张表,表中有一个字段dpt_date,SQL类型为da ...
- Date与String互相转换及日期的大小比较
private static final String PATTERN = "yyyy-MM-dd HH:mm:ss"; /** * String转Date * * @param ...
- 关于date和String互相转换的问题
其实原理很简单,就是将String类型的变量使用SimpleDateFormat来转换成Date,然后用getTime()方法比较 SimpleDateFormat sdf = new SimpleD ...
- 【MySQL】【3】String和Date相互转换
正文: 1,Date转String --结果:<2019-04-10> SELECT DATE_FORMAT(SYSDATE(), "%Y-%m-%d") FROM D ...
- Java日期与时间的处理/Date,String,Calendar转换
public class Demo01 { //Java中Date类和Calendar简介 public static void main(String[] args) { long now=Syst ...
- java Date和String转换总结
java.util.Date和String类型的转换是非常常用的,现在总结一下: 1. Date转换为String //Date --->String DateFormat dft = new ...
- java Date时间的各种转换方式和Mysql存时间类型字段的分析
一:各种Date之间的转换方法 public class TimeTest { public static void main(String[] args) { Date date = new Dat ...
随机推荐
- git上面创建个人简历-链接
github创建个人在线简历: https://segmentfault.com/a/1190000006820290
- setfacl设置特定目录的权限
现有一目录是虚拟机和linux共享的,但是每次程序调用新建的文件都发现没有权限. 于是指定特定目录及其子目录下新建的文件或目录对于用户qhfz都有读写执行的权限 -R表示递归 -m表示设置文件acl规 ...
- .NET 中如何判断文件与目录
FileInfo fileInfo = new FileInfo(pth); if ((fileInfo.Attributes & FileAttributes.Directory) != 0 ...
- Linux下安装lrzsz上传下载工具
使用yum安装 为什么要使用yum安装? 答:安装十分方便,几乎不需要别的操作,只需要一个yum命令就可以完成所有的安装过程. yum -y install lrzsz 要有网络才行 输入命令:rz ...
- Linux嵌入式 -- 内核 - 内存管理
1. 逻辑地址 线性地址 物理地址 段式管理: 16位CPU,20根地址总线,可寻址1M内存,但是只有16位的寄存器,64K. 逻辑地址 = 段基地址 + 段内偏移地址 物理地址 PA = 段 ...
- Ant入门
一.Ant介绍 Ant是Java的生成工具,是Apache的核心项目:直接在apache官网下载即可: Ant类似于Unix中的Make工具,都是用来编译.生成: Ant是跨平台的,而Make不能: ...
- js的事件处理与闭包:
var i = 0; for(i=0;i<5;i++){ (function(i){ setTimeout(function(){alert(i)},3000); })(i) } // 上面打印 ...
- 2017-02-23 .NET Core Tools转向使用MSBuild项目格式
微软之前为了让.NET Core和ASP.NET Core能够支持Windows Visual Studio之外的开发平台,创建了基于project.json格式的项目系统.不过可惜,这种格式与之前的 ...
- 185. Department Top Three Salaries
问题描述 解决方案 select b.name Department,a.name Employee,a.salary Salary from Employee a,Department b wher ...
- 有关linux下redis overcommit_memory的问题,有需要的朋友可以参考下。
我在安装redis-4.0.6后,启动时出现一些问题,如下: :M Jan ::! Background save may fail under low memory condition. To fi ...