0% found this document useful (0 votes)
2K views4 pages

MySQL Joins PDF

The document discusses different types of joins in MySQL: 1) Cross joins produce a Cartesian product by matching each row from one table with all rows of another without a WHERE clause. 2) Natural joins only include columns with matching names between tables once. 3) Right joins return all rows from the second table and matching rows from the first table. 4) Left joins return all rows from the first table and matching rows from the second table. 5) Inner joins only return rows that meet the join condition between both tables.

Uploaded by

Jeremiah Rokhum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views4 pages

MySQL Joins PDF

The document discusses different types of joins in MySQL: 1) Cross joins produce a Cartesian product by matching each row from one table with all rows of another without a WHERE clause. 2) Natural joins only include columns with matching names between tables once. 3) Right joins return all rows from the second table and matching rows from the first table. 4) Left joins return all rows from the first table and matching rows from the second table. 5) Inner joins only return rows that meet the join condition between both tables.

Uploaded by

Jeremiah Rokhum
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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