MySQL如果Date语句? [英] MySQL If Date statement?

查看:90
本文介绍了MySQL如果Date语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过mysql查询返回true或false?

Is there a way to return true or false via mysql query?

我有一个表:

id | start 
4  | 2012-03-01 00:00:00
8  | 2012-01-20 00:00:00

我想要返回 TRUE 如果当前日期大于开始日期, FALSE 如果不是。我知道我可以通过PHP进行比较,但我想知道我是否可以通过查询来做到这一点?

I'd like to return either TRUE if the current date is greater than the start date and FALSE if it isn't. I know I can do comparisons via PHP, but am wondering if I can do it via query?

推荐答案

select case now() > start_date 
         then true 
         else false
       end
from your_table

这篇关于MySQL如果Date语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆