1.
Write the sample queries to exercise all the joins – inner join, left outer join, right
outer join and full outer joins.
Tables used :
1) Palette_a 2) Palette_b
a) INNER JOIN
Description : Returns records that have matching values in both tables.
Syntax : SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
Example Query: select [Link],[Link],[Link],[Link]
from palette_a a
inner join palette_b b
on [Link]=[Link] ;
Output :
1
b) LEFT OUTER JOIN
Description : Returns all records from the left table, and the matched records
from the right table.
Syntax : SELECT column_name(s)
FROM table1
LEFT OUTER JOIN table2
ON table1.column_name = table2.column_name;
Example Query: select [Link],[Link],[Link],[Link]
from palette_a a
LEFT OUTER JOIN palette_b b
on [Link]=[Link] ;
Output :
c) RIGHT OUTER JOIN
Description : Returns all records from the right table, and the matched records
from the left table.
Syntax : SELECT column_name(s)
FROM table1
RIGHT OUTER JOIN table2
ON table1.column_name = table2.column_name;
2
Example Query: select [Link],[Link],[Link],[Link]
from palette_a a
RIGHT OUTER JOIN palette_b b
on [Link]=[Link] ;
Output :
d) FULL OUTER JOIN
Description : Returns all records when there is a match in either left or right
table.
Syntax : SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name = table2.column_name;
Example Query: select [Link],[Link],[Link],[Link]
from palette_a a
FULL OUTER JOIN palette_b b
on [Link]=[Link] ;
Output :