MySQL Joins PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

MySQL Joining Class-12 7005400409

MySQL Joins: We use join to produce values from more than one table.

1. Cross JOIN

Cross JOIN is a simplest form of JOINs which matches each row from one database table to all rows of another.

In other words it gives us combinations of each row of first table with all records in second table.

In MySQL, the CROSS JOIN produced a result set which is the product of rows of two associated tables when
no WHERE clause is used with CROSS JOIN. This kind of result is called as Cartesian Product.
MySQL Joining Class-12 7005400409

2. Natural Join
The MySQL NATURAL JOIN is structured in such a way that, columns with the same name of associate tables
will appear once only.

3. RIGHT JOIN

The MySQL RIGHT JOIN joins two tables and fetches rows based on a condition, which is matching in both
the tables and the unmatched rows will also be available from the table written after the JOIN clause.
The MySQL RIGHT OUTER JOIN would return the all records from table2 and only those records from table1
that intersect with table2
MySQL Joining Class-12 7005400409

4. LEFT JOIN

This type of join returns all rows from the LEFT-hand table specified in the ON condition and only those rows
from the other table where the joined fields are equal (join condition is met).

The MySQL LEFT OUTER JOIN would return the all records from table1 and only those records from table2
that intersect with table1.

5. INNER JOIN
MySQL Joining Class-12 7005400409
In MySQL the INNER JOIN selects all rows from both participating tables to appear in the result if and only if
both tables meet the conditions specified in the ON clause.

The MySQL INNER JOIN would return the records where table1 and table2 intersect.

Fig: Difference between Primary Key, Candidate Key and Alternate Key

You might also like