我有三张桌子:

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

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

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

EXAMPLE:
数据:参与者
1 | 2 | user1 | [email protected]

资料图:剖面图
2 | 3
2 | 4

资料:编队
1 |lable1
2 |lable2
3 |lable3
4 |lable4

任何人都可以帮助我如何使用sql语句(join)获得结果:
数据:结果
1 | 2 | user1 | [email protected] | label3
1 | 2 | user1 | [email protected] | 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/

10-14 06:29