2

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.

gideon
  • 19,329
  • 11
  • 72
  • 113
PSR
  • 39,804
  • 41
  • 111
  • 151
  • how many do you know? Did you google ? Here is the link for you. http://www.tutorialspoint.com/sql/sql-using-joins.htm –  Mar 13 '13 at 05:15
  • three i know.left join,right join ,join – PSR Mar 13 '13 at 05:16
  • http://dev.mysql.com/doc/refman/5.6/en/join.html. You can count all possible constructions. – Danil Asotsky Mar 13 '13 at 05:16
  • INNER JOIN,LEFT JOIN,RIGHT JOIN,FULL JOIN,SELF JOIN,CARTESIAN JOIN –  Mar 13 '13 at 05:17
  • 1
    I think we should **restrain** from **Answering** to this kind of **Question**. You can easily find the answer by just **Goggling** – Prahalad Gaggar Mar 13 '13 at 05:17
  • If what you find on Google is not a Stackoverflow page, then we should answer it. – Thilo Mar 13 '13 at 05:18
  • 2
    in one site i found totally we have 3 joins but in another site i saw different names whatever the first site gave.that's why i am asking – PSR Mar 13 '13 at 05:19
  • i dont know why my question is -ve.please help me – PSR Mar 13 '13 at 05:19
  • @Jw i saw a lot of good answers from u .But why are u saying like that.I am really confused.I am unable to understand these joins.Please hel me with useful answer – PSR Mar 13 '13 at 05:21
  • see http://www.tutorialspoint.com/sql/sql-using-joins.htm and http://www.w3schools.com/sql/sql_join.asp.These both are giving different no of joins.What i have to do – PSR Mar 13 '13 at 05:22
  • here's the documention from `mysql`. [MySQL Join Documentation](http://dev.mysql.com/doc/refman/5.0/en/join.html) – John Woo Mar 13 '13 at 05:24
  • @JW.did you saw my comment i gave two urls both are saying different joins .so i confused – PSR Mar 13 '13 at 05:25
  • To further gain more knowledge about joins, kindly visit the link: [Visual Representation of SQL Joins](http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html) – John Woo Mar 13 '13 at 05:27

3 Answers3

6

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
Sandy
  • 2,429
  • 7
  • 33
  • 63
4

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

Community
  • 1
  • 1
Shyam sundar shah
  • 2,473
  • 1
  • 25
  • 40
0

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
peterm
  • 91,357
  • 15
  • 148
  • 157