SQL: fixed problem on query parsing