Fix issue#689 Self-join does not work