mysql  joins

the mysql joins clause are used to combine rows from two or more tables.

you can use the join in select, update and delete statements to join mysql tables.

the following different join types are possible in mysql:

  • inner join : returns all rows when there is at least one match in both tables
  • left join : returns all rows from the left table, and the matched rows from the right                     table
  • right join : returns all rows from the right table, and the matched rows from the left                       table
  • full join : this will return all rows, as long as there's matching data in one of the                      tables.

note : you should use the on clause for conditions that specify how to join tables, and the           where clause to restrict which rows you want in the result-set.


MySQL join syntax

              select   *    from  table_name1

              inner join    table_name2
                        
              on  table_name1.column_name = table_name2.column_name
              select   *    from  table_name1

              left join    table_name2
                        
              on  table_name1.column_name = table_name2.column_name
              select   *    from  table_name1

              right join    table_name2
                        
              on  table_name1.column_name = table_name2.column_name
              select   *    from  table_name1

              full join    table_name2
                        
              on  table_name1.column_name = table_name2.column_name