我在tbl_games
中有以下字段game_id,home_team,visiting_team
我想将这些列中的数据移动到另一个名为game_team的表
game_id = game_id,home_team和visiting_team将合并到team_id下,另一列名为status将指示该团队是“家”还是“访问”
我该怎么做?
答案 0 :(得分:0)
<强>更新:强>
INSERT INTO game_team (game_id, team_id, status)
SELECT * FROM
(SELECT game_id, home_team, 'home' FROM tbl_games
UNION ALL
SELECT game_id, visiting_team, 'visiting' FROM tbl_games) q