开发者

MySQL select two tables at the same time

开发者 https://www.devze.com 2022-12-30 14:30 出处:网络
I have two tables and want to make a query. I tried to get team AA and team BB\'s image base on table A.

I have two tables and want to make a query. I tried to get team AA and team BB's image base on table A.

I used:

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

FROM tableA 

LEFT JOIN tableB ON tableA.team1=tableB.team

The result only display imageA on the column. Are there any ways to select imageA and image B without using the second query? I appreciate any helps! Thanks a lot!

My table structure are:

table A

team1 team2
------------
 AA    BB
开发者_JS百科

table B

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


That would be something like:

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

精彩评论

暂无评论...
验证码 换一张
取 消