MySQL: Using AS-variable in WHERE
08:30 19 Feb 2026

how can i use the age-field in the WHERE-clause later?

SELECT DISTINCT(TIMESTAMPDIFF(YEAR, birthday, CURDATE())) AS age FROM table WHERE age>=16 ORDER BY age ASC

It results in a #1054 error (table field "age" unknown).

Thanks!

sql mysql