日期:2014-05-17 浏览次数:20753 次
select a.number, bc.user, d.username from a left join (select name, user from b union all select name, user from c) bc on a.name = bc.name left join d on a.id = d.id
------解决方案--------------------
select a.number,bc.user,d.username
from a,d,(select name,user from b union select name,user from c)bc
where a.name=bc.name
and a.id=d.id
------解决方案--------------------
union关联了。
------解决方案--------------------
with ta as( select '1001' id,'第一号机器' name,10 num from dual union all select '1002','第二号机器',20 from dual union all select '1003','第三号机器',30 from dual union all select '1004','第四号机器',40 from dual union all select '1005','第五号机器',50 from dual) ,tb as( select '第一号机器' name,'Operator' users from dual union all select '第四号机器','Manager' from dual union all select '第三号机器','Manipulator' from dual) ,td as( select '1001' id,'James' user_name from dual union all select '1002','Smith' from dual union all select '1003','Scott' from dual union all select '1004','Jim' from dual) select ta.id,ta.name,tb.users,td.user_name from ta,tb,td where ta.id=td.id --使用等值连接即可 and ta.name=tb.name / ID NAME USERS USER_NAME ---- ---------- ----------- --------- 1001 第一号机器 Operator James 1003 第三号机器 Manipulator Scott 1004 第四号机器 Manager Jim