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 ...
随机推荐
- UVA 796 连通图求桥
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86270#problem/C#include<iostream> #inclu ...
- centos中如何寻找Nginx,Apache,PHP,mysql的配置路径
很多小伙伴都可能会碰到安装好环境之后忘记了或者不知道怎么查看配置环境的文件路径了, 下面我就来介绍centos中nginx.apache.php.mysql配置文件路径查看方法吧. 1.判断apach ...
- linux下java unrecognized class file version错误的解决
root@Mr javaPC]# java HelloWorldException in thread “main” java.lang.ClassFormatError: HelloWorld (u ...
- 派派和京东的paipai域名之争
最近有一款叫“派派”的APP很火,微博上.电梯里.群里到处都是推广广告.不仅如此,还有大张伟.关晓彤.王祖蓝等十几个明星发帖为“派派”站台.有消息称,派派这段时间仅线上推广就花去了约1600万. 总融 ...
- numpy中的matrix与array的区别
Numpy matrices必须是2维的,但是 numpy arrays (ndarrays) 可以是多维的(1D,2D,3D····ND). Matrix是Array的一个小的分支,包含于Array ...
- Spring Boot入门——Redis
1.添加redis相关依赖 2.application.properties增加redis的相关属性 3.编写redisConfig进行redis配置 4.编写测试类redisService.redi ...
- css开发素材网址
1.border-collapse 为表格设置合并边框模型 2.border-spacing border-spacing 属性设置相邻单元格的边框间的距离 backface-visibility:h ...
- jquery自定义window事件
<body> <a href='https://www.baidu.com/'>百度</a> </body> <script type=" ...
- SQL Sever删除外键
declare @sql varchar(max), @tab_name varchar(128), @fk_name varchar(128);declare c cursor forselect ...
- deep learning 自编码算法详细理解与代码实现(超详细)
在有监督学习中,训练样本是有类别标签的.现在假设我们只有一个没有带类别标签的训练样本集合 ,其中 .自编码神经网络是一种无监督学习算法,它使用了反向传播算法,并让目标值等于输入值,比如 .下图是一个自 ...