With if in a where statement I’m trying to get all rows where datetime is larger then NOW(), but if type = ‘economy’, i would like to constraint it to only show if datediff between datetime and NOW() is larger than 14 days.
Something like:
Select type,date(datetime) as date
from tbl1
where datetime > NOW()
IF(type = 'economy') && datediff(datetime,NOW()) > 14
order by datetime desc
I’ve tried with case when also, but can’t figure it out…
You can just separate the criteria into 2 different comparisons:
(Not checked for syntax errors, but the idea should be right…)