gpt4 book ai didi

mysql - SQL 连接并重复结果?

转载 作者:行者123 更新时间:2023-11-29 01:17:29 24 4
gpt4 key购买 nike

我有 3 个表:

1)participant
***********
+id_participant
+id_poste
+name
+email

2) profile_formaion
****************
+id_poste
+id_formation

3) formation
*********
+id_formation
+lable

示例:

数据:参与者

1 | 2 | user1 | user1@mail.com

数据:profile_formation

2 | 3
2 | 4

数据:形成

1 |lable1
2 |lable2
3 |lable3
4 |lable4

任何人都可以帮助我如何使用 sql 语句(连接)来获取结果:

数据:结果

1 | 2 | user1 | user1@mail.com | label3
1 | 2 | user1 | user1@mail.com | label4

谢谢

最佳答案

SELECT 
participant.id_participant,
participant.id_poste,
participant.name,
participant.email,
formation.lable
FROM participant
INNER JOIN profile_formaion ON
profile_formaion.id_poste = participant.id_poste
INNER JOIN formation ON
formation.id_formation = profile_formaion.id_formation

关于mysql - SQL 连接并重复结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13700183/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com