fixed sql query error