我想知道此SQL查询中的错误是什么

时间:2018-08-13 03:23:47

标签: sql

我已将查询更新为

SELECT regexp_substr(a.NAME, '[^:]+$') AS emp_req
    ,a.COMPLETION_STATUS
    ,b.USER_TYPE
    ,b.display_name
FROM spt_result a
    ,spt_identity b
WHERE a.name LIKE 'Join%'
AND emp_req = b.display_name;

我想从spt_result table中具有完成状态为错误或成功的spt_identity表中获取用户类型。表spt_result包含

NAME                                           COMPLETION_STATUS 
----------------------------------------------------------------
Add/Remove Role(s) for:kc051363(1503085327459) Error 
Joiner:sk080281                                Success

spt_identity contains

USER_TYPE         DISPLAY_NAME
-----------------------------
Parttime-Regular   pt092101 
Parttime-Regular   rm088923
Vendor             wl090918
Parttime-Regular   ne091924
Vendor             dh090040

1 个答案:

答案 0 :(得分:0)

加入DISPLAY_NAMENAME的出现

SELECT i.* 
FROM spt_identity i
JOIN spt_result r ON INSTR(r.name, i.display_name) > 0
WHERE r.completion_status IN ('Error', 'Success')