0

目前我有一张如下表

Table1
   hTeam-----aTeam-------date---

    3----------5 ------2012/01/01

    4 -------- 7 ------2012/01/04

    2 -------- 8 ------2012/01/05

我有一个使用双内连接来获取 id1 和 id2 的值,代码如下:

    Select hTeam As col1,
    aTeam As col2
    From fixtures as t
    Join team as d1 On ( d1.teamid = t.col1)
    Join team as d2 On ( d2.team = t.col2 )

这将创建一个像这样的表

Table2
    hTeam-------------aTeam--

    Teamname1-------TeamName1 

    TeamName2 ----- Teamname2 

    TeamName3 ----- TeamName4 

我不希望团队名称匹配,即我想要 table1 的精确复制,尽管团队名称如下

Table3
    hTeam-------------aTeam--

    Teamname3-------TeamName5 

    TeamName4 ----- Teamname7 

    TeamName2 ----- TeamName8

希望我解释得足够好。

4

1 回答 1

0

不完全确定问题是什么,因为您似乎几乎有它:

SELECT h.name AS home, a.name AS away
FROM   fixtures AS f
  JOIN team AS h ON h.teamid = f.hTeam
  JOIN team AS a ON a.teamid = f.aTeam
于 2012-10-21T08:26:40.597 回答