简体   繁体   English

MySQL同时选择两个表

[英]MySQL select two tables at the same time

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. 我试图在表A上获得AA团队和BB团队的形象。

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. 结果仅在该列上显示imageA。 Are there any ways to select imageA and image B without using the second query? 有没有不用第二个查询就可以选择imageA和imageB的方法吗? I appreciate any helps! 感谢您的帮助! Thanks a lot! 非常感谢!

My table structure are: 我的表结构是:

table A 表A

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

table B 表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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM