【问题标题】:MySQL select two tables at the same timeMySQL同时选择两个表
【发布时间】:2011-02-21 04:14:29
【问题描述】:

我有两张表,想查询。 我尝试在表 A 上获取团队 AA 和团队 BB 的图像。

我用过:

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

FROM tableA 

LEFT JOIN tableB ON tableA.team1=tableB.team

结果只在列上显示 imageA。有什么方法可以在不使用第二个查询的情况下选择 imageA 和 image B?我很感激任何帮助!非常感谢!

我的表结构是:

表A

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

表 B

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

【问题讨论】:

    标签: php mysql command


    【解决方案1】:

    应该是这样的:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-28
      • 1970-01-01
      • 2018-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      相关资源
      最近更新 更多