嗨,我在ASE中发现了很多关于在两个表中连接两列的线程,但是在使用由连接的一侧的子字符串创建的列的地方却找不到。这是用户分配数据的角色,它是从源系统中读取的,我需要从roleAssignments
字段的开头减去其他数据,然后添加前缀PRIV:ROLE:REPNAME:
才能与之匹配我在IdM数据库中拥有的东西。
我目前拥有的SQL是:
select
distinct(l.mcthismskeyvalue) as logonuid,
l.mcothermskeyvalue,
FROM idmv_link_ext l
left outer join
roleAssign s on l.mcthismskeyvalue = 'PRIV:ROLE:REPNAME' || ':' || substring(s.roleassignments,43,30) as roleAssignments2
where l.mcothermskeyvalue like 'PRIV:ROLE:REPNAME:%'
and l.mcthisocname='MX_PERSON'
and l.mcthismskeyvalue = 'TEST_MU1';
我要寻找的最终结果是,我可以看到roleAssign
上而不是idmv_link_ext
上的结果,然后反向运行以查看idmv_link_ext
上的结果而不是在roleAssign
中。在Oracle中,可以使用MINUS
语句来实现,但是在ASE中,同一命令对我不起作用。还查看了where not exists
,但也无法在那里获得语法:
select l.mcthismskeyvalue as logonuid, l.mcothermskeyvalue as roleAssignments
FROM idmv_link_ext l where mcothermskeyvalue like 'PRIV:ROLE:REPNAME%' and mcthisocname='MX_PERSON'
and l.mcthismskeyvalue = 'TEST_MU1'
where (not exists
(select s.refid as logonuid, 'PRIV:ROLE:REPNAME' || ':' || substring(s.roleassignments,43,30) as roleAssignments
FROM roleAssign s
where s.refid = 'TEST_MU1'))
;
这是使用MINUS的有效Oracle语法,以供参考:
select mcthismskeyvalue as logonuid,
* substring(mcothermskeyvalue,11,60) as roleassignments
* FROM idmv_link_ext where mcothermskeyvalue like 'PRIV:ROLE:REPNAME%' and mcthisocname='MX_PERSON'
minus
* select refid as logonuid, 'REPNAME' || ':' || substring(roleassignments,43,30) as roleAssignments
* FROM roleAssign
为了简化起见,我已经调整了ASE查询,以消除两侧都需要子字符串的情况。
非常感谢。