Question

I've heard there are 3 types of joins

I'm not sure of the exact names. Googling has turned up a variety of terms like :

Cross join , left join , right join , inner join , outer join, self join....

Could anyone tell me how many joins exist in MySQL all in all.

Was it helpful?

Solution

The joins are

1. Inner Join or Equi join
2. Self Join
2. Outer Join
   outer join is again classified into
   a) Left Outer Join
   b) Right Outer Join
   c) Full Outer Join
3. Cross join

OTHER TIPS

Please see SQL JOIN:

The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables.

Tables in a database are often related to each other with keys.

A primary key is a column (or a combination of columns) with a unique value for each row. Each primary key value must be unique within the table. The purpose is to bind data together, across tables, without repeating all of the data in every table.

Different SQL JOINs

  1. JOIN: Return rows when there is at least one match in both tables
  2. LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table
  3. RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table
  4. FULL JOIN: Return rows when there is a match in one of the tables

http://w3schools.com/sql/sql_join.asp

MySql 13.2.9.2. JOIN Syntax

join_table:
    table_reference [INNER | CROSS] JOIN table_factor [join_condition]
  | table_reference STRAIGHT_JOIN table_factor
  | table_reference STRAIGHT_JOIN table_factor ON conditional_expr
  | table_reference {LEFT|RIGHT} [OUTER] JOIN table_reference join_condition
  | table_reference NATURAL [{LEFT|RIGHT} [OUTER]] JOIN table_factor

SQL Server FROM (Transact-SQL)

<joined_table> ::= 
{
    <table_source> <join_type> <table_source> ON <search_condition> 
    | <table_source> CROSS JOIN <table_source> 
    | left_table_source { CROSS | OUTER } APPLY right_table_source 
    | [ ( ] <joined_table> [ ) ] 
}
<join_type> ::= 
    [ { INNER | { { LEFT | RIGHT | FULL } [ OUTER ] } } [ <join_hint> ] ]
    JOIN
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top