Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 tbl_games 中有以下字段
game_id、home_team、vising_team
我想将这些列中的数据移动到另一个名为 game_team 的表中
game_id=game_id 和 home_team 和visiting_team 将组合在 team_id 下,另一个名为 status 的列将指示球队是“主场”还是“客场”
我怎样才能做到这一点?
更新:
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