fixed SQL query error