zoukankan      html  css  js  c++  java
  • mysql datetime 类型查询

    https://www.cnblogs.com/sea-stream/p/11299667.html

    给的几个例子很直观,直接贴过来啦。docker里面用的mysql,最近可能会查得比较多。

    mysql> select * from table1;
    +----------+------------+-----+---------------------+
    | name_new | transactor | pid | order_date |
    +----------+------------+-----+---------------------+
    | 1hahha | 1xiaohong | 1 | 2019-08-04 20:45:47 |
    | 2hahha | 2xiaohong | 2 | 2019-08-04 20:45:57 |
    | 3hahha | 3xiaohong | 3 | 2019-08-04 20:46:02 |
    | 4hahha | 4xiaohong | 4 | 2019-08-04 20:46:05 |
    | 3hahha | bob | 5 | 2019-08-04 20:46:08 |
    | 3hahha | lee | 6 | 2019-08-04 20:46:12 |
    +----------+------------+-----+---------------------+
    6 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 | 1 | 2019-08-04 20:45:47 |
    | 2hahha | 2xiaohong | 2 | 2019-08-04 20:45:57 |
    | 3hahha | 3xiaohong | 3 | 2019-08-04 20:46:02 |
    | 4hahha | 4xiaohong | 4 | 2019-08-04 20:46:05 |
    | 3hahha | bob | 5 | 2019-08-04 20:46:08 |
    | 3hahha | lee | 6 | 2019-08-04 20:46:12 |
    +----------+------------+-----+---------------------+
    6 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 | 1 | 2019-08-04 20:45:47 |
    | 2hahha | 2xiaohong | 2 | 2019-08-04 20:45:57 |
    | 3hahha | 3xiaohong | 3 | 2019-08-04 20:46:02 |
    | 4hahha | 4xiaohong | 4 | 2019-08-04 20:46:05 |
    | 3hahha | bob | 5 | 2019-08-04 20:46:08 |
    | 3hahha | lee | 6 | 2019-08-04 20:46:12 |
    +----------+------------+-----+---------------------+
    6 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 | 1 | 2019-08-04 20:45:47 |
    | 2hahha | 2xiaohong | 2 | 2019-08-04 20:45:57 |
    | 3hahha | 3xiaohong | 3 | 2019-08-04 20:46:02 |
    | 4hahha | 4xiaohong | 4 | 2019-08-04 20:46:05 |
    | 3hahha | bob | 5 | 2019-08-04 20:46:08 |
    +----------+------------+-----+---------------------+
    5 rows in set (0.00 sec)

  • 相关阅读:
    Raknet是一个基于UDP网络传输协议的C++网络库(还有一些其它库,比如nanomsg,fastsocket等等)
    Arch Linux 是个 针对 i686 优化的 Linux 发行版(通过可以轻松使用的二进制包系统
    使用网盘(Dropbox/Google Drive)同步Git仓库
    百度网盘web端项目总结
    国内的网盘一个个倒下,这里有一份能让你用到老的存储指南(有好多评论)
    单元测试
    C# Closure
    gulp
    Net Memory Profiler 分析.Net程序内存泄露
    Net内存泄露原因及解决办法
  • 原文地址:https://www.cnblogs.com/NigelLay/p/12923904.html
Copyright © 2011-2022 走看看