MySQL error: Unknown column 'AG' in 'where clause'