【发布时间】:2019-05-17 19:43:26
【问题描述】:
所以我有这两张桌子。我需要获取表 1 第 1 行第 3 列中的任何内容(在本例中为鸭子)并将其插入表 2 第 1 行第 6 列(标记为 [此处])
table 1 (teams)
PK
team_id groupno tname oname onumber oemail group series
1 1 ducks laura 123 a@b.com A 1
2 2 birds john 456 c@d.com A 1
3 3 redds hanna 789 e@f.com A 1
4 4 blues mark 102 g@h.com A 1
team_id 和 groupno 看起来一样,groupno 最多为 10(计算一个组中的所有团队),team_id 继续
table 2 (games)
PK
game_id match_id time field group team1 team2 series
1 1 0900 1 A [here] N/A 1
2 2 0930 1 A N/A N/A 1
3 3 1000 1 A N/A N/A 1
4 4 1030 1 A N/A N/A 1
game_id 和 match_id 不一样,math_id 上升到 36(计算单系列所有游戏),game_id 继续
低于我一直在使用的东西
UPDATE games INNER JOIN teams
ON games.game_id = 1
SET games.team2 = teams.tname
WHERE teams.series=1;
我想要的结果是什么
例子:
- vs 2. --- 3. vs 4.
- vs 3. --- 2. vs 4.
- vs 4. --- 2. vs 3.
它应该取表 1 中的名字并将它们排列到游戏槽中,以便每个团队互相比赛
PK
game_id match_id time field group team1 team2 series
1 1 0900 1 A ducks birds 1
2 2 0930 1 A reds blues 1
3 3 1000 1 A ducks reds 1
4 4 1030 1 A birds blues 1
5 5 1100 1 A ducks blues 1
6 6 1130 1 A reds birds 1
【问题讨论】:
-
'WHERE table1.category=1;' - 棘手的是 table1 中没有类别?
-
请分享table1和table2中的所有字段
-
这些表之间是什么关系? “表一第三行”和“表二第一行第四列”没有关系
-
你的意思是行号还是实际ID?解决方案并不总是重叠的。
-
添加了缺少的“类别”列
标签: mysql