Can MySQL use temporary variables in a statement WHERE?
For example, in the following query:
SELECT `id`, @var := `id` * 2 FROM `user`
@var successfully set twice to id
However, if I try to filter the result set to include only the results where @var is less than 10:
SELECT `id`, @var := `id` * 2 FROM `user` WHERE @var < 10
then I get no results.
How to filter results based on @var value?
source
share