mysql - Reuse Value from SELECT in WHERE -
is possible reuse value select
in where
clause?
fine if possible other way around: reuse value where
in select
. want increase readability , performance: guess modern sql server won't calculate value twice.
select `e`.*, (datediff(e.start, 'somevalue')) `offset` `event` `e` `offset` % someinterval = 0
instead
select `e`.*, (datediff(e.start, 'somevalue')) `offset` `event` `e` (datediff(e.start, 'somevalue')) % someinterval = 0
use having
instead of where
:
select `e`.*, (datediff(e.start, 'somevalue')) `offset` `event` `e` having `offset` % someinterval = 0
where
used decide rows put result set, have infinite regress if refer results @ same time selecting them.
having
used filter results after they're calculated.
Comments
Post a Comment