Posts

Showing posts with the label SQL Join

SQL Join

Image
  SQL Joining: Joins in SQL are used to query (retrieve) data from 2 or more related tables. In general tables are related to each other using foreign key constraints. In SQL there are different types of JOINS: 1. CROSS JOIN 2. INNER JOIN 3. OUTER JOIN Outer Joins are again divided into 3 types: 1. Left Join or Left Outer Join 2. Right Join or Right Outer Join 3. Full Join or Full Outer Join General Formula for Joins SELECT       ColumnList FROM            LeftTableName JOIN_TYPE   RightTableName ON                  JoinCondition CROSS JOIN: CROSS JOIN, produces the Cartesian product of the 2 tables involved in the join. Cross Join shouldn't have ON clause. CROSS JOIN Query: SELECT ColumnName1, ColumnName2, ColumnName3,ColumnName4 FROM tableName CROSS JOIN tableName2(joining...