Alias issue in WHERE conditions


If I change the WHERE clause by:
WHERE order_id = ‘6’ AND total_price > ‘30’
I do not get an answer.

The original data doesn’t include the total_price column but I created one using the Select clause.
After that when I try to use the total_price column in the WHERE condition, it doesn’t work until I use the actual data (unit_price * quantity). Why is this so?

According to the MySQL docs, we’re not allowed to use an alias in the WHERE clause because the WHERE clause can be evaluated before alias values are calculated i.e. we can’t rely on alias values being available when the WHERE clause is evaluated.