Page 57 - Modular_V2.0_SQL_Flipbook
P. 57
NATURAL JOIN
A Natural Join is used when two tables are joined based on a column that is identical (i.e., has the
same name and compatible data type) in both tables. The join automatically matches rows using this
column without explicitly specifying the join condition.
Syntax:
SELECT column1, column2, ...
FROM table1
NATURAL JOIN table2;
Example using tables: STU and GAMES
SELECT Game_played, Name
FROM GAMES NATURAL JOIN STU;
Output:
+-------------+--------+
| Game_played | Name |
+-------------+--------+
| Cricket | Isha |
+-------------+--------+
| Rugby | Manish |
+-------------+--------+
| Football | Karan |
+-------------+--------+
INNER JOIN
INNER JOIN
An INNER JOIN is a way to combine data from two or more tables based
on a common column that they share. It returns only the rows where the
values in the common columns are exactly the same in both tables. If Table 1 Table 2
there is no match between the tables, those rows are not shown in the
result.
Syntax:
SELECT table1.column1, table2.column2
FROM table1
INNER JOIN table2
ON table1.common_column = table2.common_column;
Now consider the following tables:
STAFF
Staff_id Staff_name Role Location
101 Rohit Manager Mumbai
102 Amisha Supervisor Delhi
103 Neha Assistant Bangalore
55
Advanced Features of MySQL

