Syntax error fix in query