0

我有 3 个如下表

table_1

securityno name    price
1           a11    12.12
2           z11    44.4

table_2

name      identifier Mainprice
a11_bond  NO34         11
z22_bond  NO98         22



table_3
securityno name    identifier 
1           a11    NO34         
2           z11    NO98         

我想检查table_1价格是否正确,因为table_2 我只想显示输出table_1数据和Mainpricetable_2

securityno name    price Mainprice
1           a11    12.12 11
2           z11    44.4  22

我试着像

select * from table_1 left join table_2 on table_3呢?

未能使用 3 张桌子。

请帮忙。

4

2 回答 2

2

尝试:

SELECT  
    t1.*,  
    t2.Mainprice  
FROM table_1 AS t1  
LEFT JOIN table_3 AS t3  
   ON t1.securityno = t3.securityno AND t1.name = t3.name  
INNER JOIN table_2 AS t2  
   ON t2.identifier = t3.identifier  
于 2013-04-09T18:37:24.857 回答
2

简单使用INNER JOIN

SELECT T1.*,
       T2.mainprice
FROM TABLE1 T1
INNER JOIN Table3 T3 ON T3.securityno = T1.securityno
INNER JOIN Table2 T2 ON T2.identifier = T3.identifier

演示

于 2013-04-09T19:05:44.900 回答