如何处理两个分离的内连接



>im 在做一个查询,我遇到了一点麻烦。这是我的查询:

SELECT u. file_id, u.row_id, u.col005,
       cl.client_id, cl.name
FROM uimp_buf_in u 
INNER JOIN(
SELECT c.client_id, c.name FROM clients c
)cl ON convert(REPLACE(REPLACE(REPLACE(LOWER(cl.name), ' '), '-'),extract_title(cl.name)),'us7ascii')=
       convert(REPLACE(REPLACE(REPLACE(LOWER(u.col005), ' '), '-'),extract_title(u.col005)),'us7ascii') 
INNER JOIN(
SELECT us.idusr, us.full_name FROM USERS us
)us ON convert(REPLACE(REPLACE(REPLACE(LOWER(us.full_name), ' '), '-'),extract_title(us.full_name)),'us7ascii')=
       convert(REPLACE(REPLACE(REPLACE(LOWER(u.col005), ' '), '-'),extract_title(u.col005)),'us7ascii') 
WHERE u.file_id = 850

有没有办法显示第一个内部连接的结果,并在它下面显示第二个内部连接的结果?就像两个单独的比较,但在一个查询中?换句话说,我需要获得第一次连接的结果,然后从第二个连接开始,但没有第一次连接以任何方式影响第二个。

谢谢。

如果您希望 2 个查询的结果出现在单个输出中,那么您可能希望使用 UNION 或 UNION ALL

https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries004.htm

我已经尝试过分离您的代码并将它们组合在一起,但我还没有测试过它。

SELECT
    c.client_id,
    c.name
FROM
    clients c
INNER JOIN
    uimp_buf_in u 
ON  convert(REPLACE(REPLACE(REPLACE(LOWER(cl.name), ' '), '-'),extract_title(cl.name)),'us7ascii')
  = convert(REPLACE(REPLACE(REPLACE(LOWER(u.col005), ' '), '-'),extract_title(u.col005)),'us7ascii')
WHERE
    u.file_id = 850
UNION ALL
SELECT
    us.idusr,
    us.full_name
FROM
    USERS us
INNER JOIN
    uimp_buf_in u
ON  convert(REPLACE(REPLACE(REPLACE(LOWER(us.full_name), ' '), '-'),extract_title(us.full_name)),'us7ascii')
  = convert(REPLACE(REPLACE(REPLACE(LOWER(u.col005), ' '), '-'),extract_title(u.col005)),'us7ascii')
WHERE
    u.file_id = 850

最新更新