Unknown Column In Where Clause

mysql, mysql-error-1054, sql

Solution

SQL is evaluated backwards, from right to left. So the where clause is parsed and evaluate prior to the select clause. Because of this the aliasing of u_name to user_name has not yet occurred.

Problem

I have a simple query: ``` SELECT u_name AS user_name FROM users WHERE user_name = "john"; ``` I get `Unknown Column 'user_name' in where clause`. Can I not refer to `'user_name'` in other parts of the statement even after `select 'u_name as user_name'`?

Original source