MySQL - Joins
MySQL - Joins
A MySQL JOIN is performed whenever two or more tables are joined in a SQL
statement.
Syntax :
SELECT columns
FROM table1
ON table1.column = table2.column;
Supplier Orders
10003 NVIDIA
Example
SELECT columns
FROM table1
LEFT [OUTER] JOIN table2
ON table1.column = table2.column;
Example
FROM table1
ON table1.column = table2.column;
FULL OUTER join
MySql does not support full outer join. But we can implement with the help of
UNION.
SELECT columns
FROM table1
LEFT [OUTER] JOIN table2
ON table1.column = table2.column
UNION
SELECT columns
FROM table1
RIGHT [OUTER] JOIN table2
ON table1.column = table2.column;
Natural Join
In MySQL, the NATURAL JOIN is such a join that performs the same task as an
INNER or LEFT JOIN, in which the ON or USING clause refers to all columns that
the tables to be joined have in common.
The MySQL NATURAL JOIN is structured in such a way that, columns with the
same name of associate tables will appear once only.
Natural Join Guidelines:
● The associated tables have one or more pairs of identically named columns.
● The columns must be the same data type.
● Don’t use ON clause in a NATURAL JOIN.
Natural Join
SELECT columns
FROM table1
FROM table1
Courses Student
CourseID Coursetitle Category Fees Adno Studname Courseid