我不能让教练把运动员的名字排成一行
SELECT dev_test_team.team_id, dev_test_team.team_name,
dev_test_team.user_id, `dev_user`.`user_id` as `athlete_id`,
`dev_user`.`user_type` FROM `dev_test_team`
CROSS JOIN `dev_user`
INNER JOIN `dev_test_teams_athlete` as `tt` ON `dev_user`.`user_id` = `tt`.`user_id` GROUP BY dev_test_team.team_id, dev_test_team.team_name, dev_test_team.user_id
这是对查询使用交叉连接关键字时的结果
我的dev\u test\u团队表是:
我的开发测试团队运动员表是:
我的dev\u user表是:
最后,我希望结果如表所示
----------------------------------------------------------------------------
|first_name(coach_name)| first_name(athlete_name) | team_id | team_name
---------------------------------------------------------------------------
coach1 athlete1 1 ind
coach2 athlete2 2 usa
coach3 athlete3 3 uk
coach3 athlete4 3 uk
1条答案
按热度按时间2ledvvac1#
你可以试着
JOIN
在dev_user
两张table。一个给
dev_test_teams_athlete
table。另一个给我
dev_test_team
table。查询1:
结果: