我有3张表ORACLE10G 以WORKFLOW_BASE为基准, HRMSUBCOMPANY 和 WORKFLOW_TYPE
1。WORKFLOW_BASE和HRMSUBCOMPANY
SELECT a.ID 工作流ID,a.WORKFLOWNAME 工作流名称,a.WORKFLOWTYPE 类型,a.SUBCOMPANYID 分部ID ,a.SUBCOMPANYID 公司ID,c.SUBCOMPANYNAME 公司名称
FROM WORKFLOW_BASE a left join HRMSUBCOMPANY c on (a.SUBCOMPANYID=c.ID);
2。WORKFLOW_BASE和WORKFLOW_TYPE
SELECT a.ID 工作流ID,a.WORKFLOWNAME 工作流名称,a.WORKFLOWTYPE 类型,a.SUBCOMPANYID 分部ID ,a.SUBCOMPANYID 公司ID,b.TYPENAME
FROM WORKFLOW_BASE a left join WORKFLOW_TYPE b on(a.WORKFLOWTYPE=b.ID);
怎么写3张表同时连接起来的查询:以第一张为基准。3张以上又怎么做
------解决方案--------------------
一般是如果3张表A,B,C,以A表为基础。则是
select *
from a left join b on a.id=b.id
left join c on a.id=c.id
------解决方案--------------------
select * from WORKFLOW_BASE a left oin HRMSUBCOMPANY b on a.SUBCOMPANYID=c.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
------解决方案--------------------
select *
from WORKFLOW_BASE a left join HRMSUBCOMPANY b on a.SUBCOMPANYID=b.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
------解决方案--------------------
select * from a left join b on a.id=b.id left join c on a.id=c.id 应该是最常用的方法。。。