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