普通网友 2013-08-27 23:38
浏览 56

此查询(SELECT JOIN SUM ON)在另一个项目之前运行良好,但现在却没有

The below query worked fine on another project (SQL), however now it seems to give no results and i do not get why. Have search allready for hours on the web for solutions. I have 2 tables, one GOALS (id_goals, season, player, goalsscored, assists, team) and another PLAYERS (id_player, name, and some more fields not important for this matter). id_player from PLAYERS is used in player field in GOALS. Now i want to display the name of the players and the total goals they have scored as well as the total assists they have made in a certain season for a certain team and this is the query I am using (but does not work anymore):

mysql_select_db($database_check_mag, $check_mag);
$query_getPosts = "SELECT id, tot_goals, player_name, tot_assists FROM
(SELECT g.player id, SUM(g.goalsscored) tot_goals, SUM(g.assists) tot_assists,
g.season, s.name player_name, s.id_player FROM goals g JOIN players s ON 
g.player = s.id_player WHERE g.season = 20132 AND g.team = 39   
GROUP BY g.player) sums GROUP BY id ORDER BY tot_goals DESC";

Can somebody help me and tell me what I do wrong?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类
    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据