Joins in SQL

JOINS IN SQL 



Joins are used to combine row from two or more tables, based on a related column between them. 

Types of Joins in MySQL  are -:

  • Inner Joins
  • left Joins
  • Right Joins
  • Cross Joins

Now we will  explain in details with examples
  • Inner Joins The SQL 'INNER JOIN' statement joins two tables based on a common column and selects rows that have matching values in these columns.



  • INNER JOIN, which tells the SQL engine the name of the table you wish to join in your query, and that you wish to use an inner join.
  • ON, which tells the SQL engine what columns to use to join the two tables.

       Joins are usually used in a query after the FROM clause. 





  • Left Joins- Returns all record from the Left table, and the matching records from the Right table.





  •   While the left join includes all rows in the table before the JOIN  clause.

  • Right Joins- Returns all record from the Right table, and the matching records from the Left table.





  • The right join includes all rows in the new table in the JOIN clause.



  • Cross Joins- Returns all records from both tables.







Comments

Popular posts from this blog

Most Asked SQL Queries on Interviews