2010-05-19 70 views
5

我有两个表并想进行查询。 我试图让球队AA和表A队BB的形象基础MySQL同时选择两个表

我用:

SELECT tableA.team1, tableA.team2, tableB.team, tableB.image, 

FROM tableA 

LEFT JOIN tableB ON tableA.team1=tableB.team 

结果只列显示imageA。有没有办法选择imageA和图像B而不使用第二个查询?我感谢任何帮助!非常感谢!

我的表结构是:

表一

team1 team2 
------------ 
AA BB 

表B中

team image 
------------- 
    AA imagaA 
    BB imageB 

回答

6

这将是这样的:

SELECT tableA.team1, tableA.team2, tableB.team, tableB.image, tb.image 

FROM tableA 

LEFT JOIN tableB ON tableA.team1=tableB.team 
LEFT JOIN tableB tb ON tableA.team2=tb.team 
+0

真棒!!!!感谢Jeroen的快速回复! – FlyingCat 2010-05-19 01:24:57

+0

不客气! – jeroen 2010-05-19 01:44:53