Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is the join in MySQL ?

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 83
    Comment on it

    Welcome to findnerd, today we are going to discuss to join in MySQL.

    Firstly let know what is join ?

    An SQL JOIN clause is used to combining two or more tables and return output in single table.
    So in simple word we can say that MySQL joins basically merge two or more than two tables together to form a single table.

    There are mainly four types of join in MySQL,these are given bellow.

     1-Inner join 
     2-Outer join
     3-Left join 
     4-Right join 
    

    Now let explain one by one

    1-Inner join:- Inner join returns all rows when there is at least one match in BOTH tables,
    means if there is any common key(primary and foreign key) in both tables.

    syntax of inner join

     SELECT column_name(s)
      FROM table1
      JOIN table2
      ON table1.column_name=table2.column_name;
    

    2-Outer join:-Outer join displays all rows from left table and right table. if there are rows in left table which does not matches with the rows in right table , those rows will also be displayed and viceversa.

    syntax of FULL outer join

    SELECT column_name(s)
        FROM table1
        FULL OUTER JOIN table2
        ON table1.column_name=table2.column_name;
    

    3-Left join:-Left join return all rows from the left table, if there is no match in the right table.

    syntax of left join

    SELECT column_name(s)
      FROM table1
      LEFT JOIN table2
      ON table1.column_name=table2.column_name;
    

    4-Right join:-Right join return all rows from the right table, af there is no match in the left table.

    syntax of right join

     SELECT column_name(s)
        FROM table1
        RIGHT JOIN table2
        ON table1.column_name=table2.column_name;
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: