zoukankan      html  css  js  c++  java
  • 项目中 mysql中的内容关于上架时间和下架时间

    在mysql中,是存放的10位的时间截,在后台添加时,时间的格式是:'Y-m-d H:i',没有秒的

    字段

    字段名称 字段类型 是否为空 默认值 备注
    publish_up int(11) 0 上架时间
    publish_down int(11) 0 下架时间

     我的想法是:

    时间截为0,就是没有限制的,我就列出可能出现的情况,4种组合

    组合编号 上架时间(publish_up) 条件符号 当前时间(unix_timestamp()) 下架时间(publish_down) 条件符号 当前时间(unix_timestamp())
    1 0  = 0 0  = 0
    2 2015-10-27 16:30 <= 2015-10-27 16:30  0  = 0
    3 0  = 0 2015-10-27 18:00 >= 2015-10-27 16:30 
    4 2015-10-27 16:30 <= 2015-10-27 16:30  2015-10-27 16:58 >= 2015-10-27 16:30 

    所以mysql的判断上架时间和下架时间的条件sql语句是

    1 ( (publish_up = 0 AND publish_down = 0) or (publish_up <= unix_timestamp() AND publish_down = 0 ) or (publish_up = 0 AND publish_down >= unix_timestamp()) or (publish_up <=  unix_timestamp() AND publish_down >=  unix_timestamp()) )
  • 相关阅读:
    CCF NOI1062 计算曼哈顿距离
    CCF NOI1061 Wifi密码
    CCF NOI1073 放苹果
    CCF NOI1072 爬楼梯
    CCF NOI1071 Pell数列
    CCF NOI1064 计算斐波那契第n项
    NOI训练行动路线图
    CCF NOI1060 雷同检测
    CCF NOI1059 表达式求值
    CCF NOI1057 石头剪刀布
  • 原文地址:https://www.cnblogs.com/fsong/p/4914888.html
Copyright © 2011-2022 走看看