Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in SQL by (6.1k points)

I can presently query the join of two tables on the equality of a foreign/primary key in the below way:

 $result = mysql_query("SELECT * FROM `table1` 
                         INNER JOIN 
                       `table2` ON table1.primaryKey=table2.table1Id");

I want to extend this to multiple tables (all with the same foreign keys). I am attempting the following code which isn't returning anything. Can anyone help me with this?

1 Answer

0 votes
by (12.7k points)

You can use the below code:

SELECT * 
FROM table1 
INNER JOIN table2
      ON table1.primaryKey=table2.table1Id
INNER JOIN table3
      ON table1.primaryKey=table3.table1Id

Interested in SQL?  Register to the SQL Certification course and get certified.

If you want to know more about Inner Join, refer to the below SQL Inner Join tutorial video that will help you out in a better way:

Related questions

0 votes
1 answer
0 votes
1 answer
+3 votes
1 answer
asked Jul 3, 2019 in SQL by Tech4ever (20.3k points)

Browse Categories

...