0

请帮我解决这个问题

sel a.col1,a.co2,a.col3,.........b.col1,b.col2..,c.col1,c.col2
from table1 as a inner join table2 as b on a.col1 =b.col1
inner join table3 as c on a.col1 = b.col1
where col1 = xxxxx;

现在我需要再加入一个表table4。由于 table4 中没有 col1 作为主索引,因此我需要将其加入到另一个具有主键的表中。

以下是我需要将其包含在上述 sel 语句中的不同查询。

Sel xx.col1,yy.aaa,yy.bbb,zz.ccc,zz.ddd,zz.eee
from tablea as xx, tableb as yy, table4 as zz
where xx.col1 = yy.bbb and yy.aaa = zz.ccc

主要指标:

  • col1 用于表 1、表 2、表 3、表 xx
  • 用于tableb的aaa
  • 表4的ccc

提前致谢

4

1 回答 1

1

怎么样:

Select a.leg,c.btn,p.prods,svc.sr,speed.test, a.leg, b.acct_id, e.emp_no, e.emp_name
FROM db1.tb1 as a 
    inner join db1.tb2 as C ON a.leg = C.leg 
    inner join db1.tb3 as p ON a.leg = p.leg 
    inner join db1.tb3 as svc on a.leg = svc.leg 
    inner join db2.tb4 as speed on a.leg = speed.leg
    inner join db4.tb1 as b on a.leg = b.sce_acct_id
    inner join db4.tb5 as e on b.acct_id = e.acct_id
where a.leg ='xxxx' 
于 2012-08-09T16:35:38.843 回答