I have this following query and I want to display the results where masini > 2 but when I run the query it says that 'masini' is not an existing column but it's the name of a custom column I defined on the first row. I am new to MySQL.. can anyone point me in the right direction? This is my query:
SELECT pers.serie_buletin AS persoana, COUNT(prop.serie_buletin) AS masini
FROM persoana pers
JOIN proprietate prop
ON pers.id_persoana = prop.serie_buletin
WHERE masini > 2
GROUP BY persoana ;
I defined the column on this line, in this part "COUNT(prop.serie_buletin) AS masini" but it says "Error Code: 1054. Unknown column 'masini' in 'where clause'". What am I missing?