Fix query syntax error