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张以上又怎么做
6 个解决方案
#1
一般是如果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 a left join b on a.id=b.id
left join c on a.id=c.id
#2
好的谢谢试验一下看看
#3
select * from WORKFLOW_BASE a left oin HRMSUBCOMPANY b on a.SUBCOMPANYID=c.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
#4
select *
from WORKFLOW_BASE a left join HRMSUBCOMPANY b on a.SUBCOMPANYID=b.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
from WORKFLOW_BASE a left join HRMSUBCOMPANY b on a.SUBCOMPANYID=b.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
#5
select * from a left join b on a.id=b.id left join c on a.id=c.id 应该是最常用的方法。。。
#6
#1
一般是如果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 a left join b on a.id=b.id
left join c on a.id=c.id
#2
好的谢谢试验一下看看
#3
select * from WORKFLOW_BASE a left oin HRMSUBCOMPANY b on a.SUBCOMPANYID=c.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
#4
select *
from WORKFLOW_BASE a left join HRMSUBCOMPANY b on a.SUBCOMPANYID=b.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
from WORKFLOW_BASE a left join HRMSUBCOMPANY b on a.SUBCOMPANYID=b.ID
left join WORKFLOW_TYPE c on a.WORKFLOWTYPE=c.ID
#5
select * from a left join b on a.id=b.id left join c on a.id=c.id 应该是最常用的方法。。。