Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何更改此mysql查询以包含另一个mysql表?_Mysql_Sql_Join - Fatal编程技术网

如何更改此mysql查询以包含另一个mysql表?

如何更改此mysql查询以包含另一个mysql表?,mysql,sql,join,Mysql,Sql,Join,之前我问了一个关于根据足球成绩列表创建一个表格的问题,但我忘了添加,后来意识到缺少了一些东西,基本上我想在输出表格中包含一个俱乐部徽章 这是在浏览器中动态创建输出表的代码 $sqlCommand = " select team, count(*) played, count(case when goalsfor > goalsagainst then 1 end) wins, count(case when goalsagainst> goals

之前我问了一个关于根据足球成绩列表创建一个表格的问题,但我忘了添加,后来意识到缺少了一些东西,基本上我想在输出表格中包含一个俱乐部徽章

这是在浏览器中动态创建输出表的代码

$sqlCommand = " 
    select team, 
    count(*) played,
    count(case when goalsfor > goalsagainst then 1 end) wins, 
    count(case when goalsagainst> goalsfor then 1 end) lost, 
    count(case when goalsfor = goalsagainst then 1 end) draws,
    sum(goalsfor) goalsfor, 
    sum(goalsagainst) goalsagainst, 
    sum(goalsfor) - sum(goalsagainst) goal_diff,
    sum(case when goalsfor > goalsagainst then 3 else 0 end 
        + case when goalsfor = goalsagainst then 1 else 0 end)score 
   from (select hometeam team, homebadge badge, goalsfor, goalsagainst from serie_a_2010_2011
   union all
         select awayteam, awaybadge, goalsagainst, goalsfor from serie_a_2010_2011) a
   group by team
   order by score desc, goal_diff desc";
我在数据库中创建了另一个名为badges的表,其结构如下

     ----------------------------------------------
    | id | team    |    badge                      |
     ----------------------------------------------
    |  1 | Inter   | (link to image of Inter badge)|
     ----------------------------------------------
    |  2 | Milan   | (link to image of Milan badge)|
     ----------------------------------------------
etc etc
这包括将在排名表中输出的所有团队


如何创建/添加/加入/额外查询,为正确的团队输出正确的徽章?

我会说在所选字段列表中添加
badges\u table.badge
(选择之后)

然后将
LEFT JOIN-badges\u table ON-badges\u table.id=tablethasback.badgeField
添加到组的前面,这应该可以让您继续:)


如果您仍有问题,请告诉我

它似乎不起作用,不断收到关于不存在的表和列的错误。。。。表和列都在那里。。。。