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 ...
随机推荐
- DBUtiles中的简单使用(QueryRunner和ResultSetHandler的手动实现)
DBUtiles是一个很好的处理JDBC的工具类.(DbUtils is a small set of classes designed to make working with JDBC easie ...
- asp.net 5 (mvc 6) 获取网站的物理路径
public static IApplicationEnvironment GetApplication(this RazorPage page) { var ae = page.Context.Re ...
- javaMail发送邮件实例
背景:最近项目里有个实时发送邮件的功能,今天闲下来整理 一下,记录下来方便以后直接使用. 代码: package com.dzf.utils; import java.io.File; import ...
- UVA 10200 Prime Time 水
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- Eclipse导出apk
http://jingyan.baidu.com/article/7908e85c8dea30af491ad24f.html
- Swagger自动生成接口文档
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...
- jquery的队列问题
队列,可以当成一个数组,也可以当成一个空间. 使用的地方: 在js这种异步操作的时候,我们不知道什么时候一个js代码加载完成,并且你还要保护一段代码只有一个模块在执行(按需加载的时候) 这个时候我们就 ...
- PHP 5.2、5.3、5.4、5.5、5.6 版本区别对比以及新功能详解
截至目前(2015.1), PHP 的最新稳定版本是 PHP5.5, 但有差不多一半的用户仍在使用已经不在维护 的 PHP5.2, 其余的一半用户在使用 PHP5.3 . 因为 PHP 那“集百家之 ...
- mysql数据库优化课程---2、命令其实也就是那几个单词
mysql数据库优化课程---2.命令其实也就是那几个单词 一.总结 一句话总结: 比如show,use,alter 1.开启和关闭mysql服务? Windows下:net start/stop m ...
- Windows平台下Qt QOpenGL中glutSolidSphere()方法未定义的解决方法
Windows平台下Qt中glut库的使用 用Qt中的QGLWidget窗体类中是不包括glut工具库的,难怪在myGLWidget(在我的程序中是QGLWidget的派生类)中绘制实心球体是 ...