Column 'rid_type' in on clause is ambiguous