ERROR 1054(42S22):一個match_results(:未知列在 'where子句'什麼是錯的這個sql查詢ERROR 1054(42S22)
(select m.match_id,m.team1,m.team2,m.team1_score from match_results as m where m.team1_score=( select max(score) from ( select p.team1_score as score from match_results p where p.match_id=m.match_id UNION select q.team2_score as score from match_results q where q.match_id=m.match_id ) as T )) UNION (select m1.match_id,m1.team1,m1.team2,m1.team2_score from match_results m1 where m1.team2_score=( select max(score) from ( select team1_score as score from match_results where match_id=m1.match_id UNION select team2_score as score from match_results where match_id=m1.match_id )as T ));
模式 'm.match_id' match_id,team1,team2,team1_score,team2_score) team1和team2是varchar() team1_score和team2_score是整數。 我想取隊以最高分(TEAM1_SCORE或TEAM2_SCORE))
您需要發佈架構和錯誤消息或您需要的操作。 – user2182349
你有什麼錯誤? –
您在UNION的兩個查詢中都沒有選擇相同數量的列。第一個查詢在select中沒有'match_id'。你需要在第一個選擇查詢的開始處添加'm.match_id' –