Select Chapter ❯
MySQL Joins is used to get results from two or more tables and combine them in a single result sets most common type of join is inner join.
Syntax of INNER JOIN
SELECT columnList from table1 [INNER] JOIN table2 ON joinCondition1 [INNER] JOIN table3 ON joinCondition2....
Example of INNER JOIN
SELECT student_name, physics_marks FROM student_info INNER JOIN student_marks ON student_info.student_name = student_marks.name
- In this example we combine two tables studen_info and student_marks using inner join.
- In this we get student_name from studen_info table and physics_marks from student_marks table.
- In this we get every row if student_name from studen_info is equal to name from student_name.
- You must use tableName.columnName syntax in writting the conditions.
Join Tables from another Database
SELECT columnList from table1 [INNER] JOIN databasename.table2 ON joinCondition1 [INNER] JOIN table3 ON joinCondition2....