Date post: | 18-Jul-2015 |
Category: |
Software |
Upload: | transys-info-solutions-pvt-ltd |
View: | 39 times |
Download: | 3 times |
3
SQL JOINS
I.INNER JOIN
Inner join returns only those records that match in both the tables.
Syntax:Select * from table 1 INNER JOIN table 2ONTable 1.Column 1=table 2.Column 1
4
SQL JOINS
Select * from CountryStatusInner Join PRODUCTSONCountryStatus.ProductID=PRODUCTS.ProductID
Result:
QUARY:
5
SQL JOINS
II.OUTER JOIN
Outer Joins are three typesa. Right Outer Joinb. Left Outer Joinc. Full Outer join
6
SQL JOINS
a. Right Outer Join
Right outer join returns all records/rows from right table and from left tablereturns only matched records.
Syntax:
Select * from Table 1Right Outer Join Table 2ONTable 1.Column 1=Table 2.Column 1
7
SQL JOINS
QUARY:
Select * from CountryStatusRight Outer Join PRODUCTSONCountryStatus.ProductID=PRODUCTS.ProductID
RESULT:
8
SQL JOINS
b. Left Outer Join
Left outer join returns all records/rows from left table and from right table returns only matched records.
Syntax:
Select * from Table 1Left Outer Join Table 2ONTable 1.Column 1=Table 2.Column 1
9
SQL JOINS
RESULT:
QUARY:Select * from CountryStatusLeft Outer Join PRODUCTSONCountryStatus.ProductID=PRODUCTS.ProductID
10
SQL JOINS
c. Full Outer Join
Full outer join combines left outer join and right outer join. This join returns all records/rows from both the tables.
Syntax:
Select * from Table 1Full Outer Join Table 2ONTable 1.Column 1=Table 2.Column 1
11
SQL JOINS
QUARY:
Select * from CountryStatusFull Outer Join PRODUCTSONCountryStatus.ProductID=PRODUCTS.ProductID
RESULT:
12
SQL JOINS
III. Cross Join
This join returns records/rows that are multiplication of record number from both the tables means each row on left table will related to each row of right table.
Syntax:
Select * from Table 1Cross Join Table 2