I am having some problems with a query.
It's rather long so I'll stick with the problematic parts.
I select from different tables and left join them together.
One value has to be calculated. It's the delay in minutes calculated from unix timestamps and looks like this:
ROUND(TIME_TO_SEC(TIMEDIFF(FROM_UNIXTIME(base.departure_forecast), FROM_UNIXTIME(base.departure)))/60) AS delay
This works very well.
I then wanted to use the value "delay" in the where condition.
However I can't seem to use it there.
Using this one worked however:
The problem I am having now is a bit more complicated as I need to extend my where condition.
I need the departure time + delay to be before the current time.
Which would look something like this:
AND (base.departure + (delay * 60)) > 1372658400
The timestamp is inserted via my php script, but as stated earlier: "delay" is not available in the where condition.
If I add the condition to the "having" part, the "base.departure" column is not available. So the same problem, but the other way round...
Is there a way to make it available without an additional query?
thanks a lot in advance and kind regards