Joining three tables using MySQL

前端 未结 9 2404
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 10:40

I have three tables named

**Student Table**
-------------
id    name
-------------
1     ali
2     ahmed
3     john
4     king

**Course Table**
------------         


        
9条回答
  •  日久生厌
    2020-11-22 11:11

    Use ANSI syntax and it will be a lot more clear how you are joining the tables:

    SELECT s.name as Student, c.name as Course 
    FROM student s
        INNER JOIN bridge b ON s.id = b.sid
        INNER JOIN course c ON b.cid  = c.id 
    ORDER BY s.name 
    

提交回复
热议问题