MySQL Joins

Joins and Union
Inner Join The INNER JOIN/JOIN returns rows when there is at least one match in both tables.
Left Join The LEFT JOIN returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2).
Right Join The RIGHT JOIN returns all the rows from the right table (table_name2), even if there are no matches in the left table (table_name1).
Full Join The FULL JOIN/ FULL OUTER JOIN return all rows when there is a match in one of the tables or not.The FULL OUTER JOIN keyword combines the result of both LEFT and RIGHT joins.
Union The UNION operator is used to combine the result-set of two or more SELECT statements.
  Notice that each SELECT statement within the UNION must have the same number of columns. The columns must also have similar data types. Also, the columns in each SELECT statement must be in the same order.
UNION ALL The UNION operator selects only distinct values by default. To allow duplicate values, use UNION ALL.
  In MySQL, JOIN, CROSS JOIN, and INNER JOIN are syntactic equivalents (they can replace each other). In standard SQL, they are not equivalent. INNER JOIN is used with an ON clause, CROSS JOIN is used otherwise.
  INNER JOIN and , (comma) are semantically equivalent in the absence of a join condition: both produce a Cartesian product between the specified tables (that is, each and every row in the first table is joined to each and every row in the second table).

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>