[英]mysql query - How to write if condition on where
i have query for checking if close_at >= '00:00' + interval 1 day else not add interval. 我有查询要检查close_at> = '00:00'+间隔1天,否则不添加间隔。 my query is:
我的查询是:
select * from table where now() between open_at and if(close_at >= '00:00' close_at + INTERVAL 1 day, close_at - INTERVAL 1 day) 从表中选择*,其中now()在open_at和if之间(close_at> = '00:00'close_at + INTERVAL 1天,close_at-INTERVAL 1天)
在where条件下,您可以根据业务逻辑编写case条件。
SELECT id
, naam
FROM klanten
WHERE IF('close_at' >= '00:00' 'close_at' + INTERVAL 1 day, 'close_at' - INTERVAL 1 day) LIKE 'some condition' SELECT
id
, naam
FROM klanten
WHERE IF('close_at'> = '00:00''close_at'+间隔1天,'close_at'-间隔1天)像'某种情况'
The structure is like this but i dont know what is a constant or a attribute, use the simple quote correctly. 结构是这样的,但我不知道什么是常量或属性,请正确使用简单的引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.