简体   繁体   中英

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. 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)

在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'

The structure is like this but i dont know what is a constant or a attribute, use the simple quote correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM