SQL Inner join more than two tables

后端 未结 10 1161
感情败类
感情败类 2020-11-29 23:21

I can currently query the join of two tables on the equality of a foreign/primary key in the following way.

 $result = mysql_query(\"SELECT * FROM `table1` 
         


        
10条回答
  •  野性不改
    2020-11-30 00:23

    Please find inner join for more than 2 table here

    Here are 4 table name like

    1. Orders
    2. Customers
    3. Student
    4. Lecturer

    So the SQL code would be:

    select o.orderid, c.customername, l.lname, s.studadd, s.studmarks 
    from orders o 
        inner join customers c on o.customrid = c.customerid 
        inner join lecturer l  on o.customrid = l.id 
        inner join student s   on o.customrid=s.studmarks;
    

提交回复
热议问题