The JOIN is used to combine rows from two or more tables.
SQL Inner Join :-
Select all rows from tables for the match between the columns in tables.
Same as JOIN
Syntax :-
SELECT column FROM table1
INNER JOIN table2
on table1.column = table2.column;
[only matching rows are retrieved]
Example :-
SELECT emp.eno, emp.ename, dept.dno, dept.dname FROM emp
INNER JOIN dept
on emp.dno = dept.dno;
SQL LEFT JOIN :-
Returns all rows from the left table, with the matching rows in the right table.
The result is NULL in the right side when there is no match.
Syntax :-
SELECT Columns FROM table1
LEFT [OUTER] JOIN table2
on table1.column = table2.column;
Example :-
SELECT emp.eno, emp.ename,dept.dno, dept.dname FROM emp
LEFT JOIN dept
on emp dno = dept.dno;
SQL RIGHT JOIN :-
Returns all rows from the right table, with the matching rows in the left table.
The result is NULL in the left side when there is no match.
Syntax :-
SELECT columns FROM table1
RIGHT [OUTER] JOIN table2
on table1.column = table2.column;
Example :-
FULL OUTER JOIN
Returns all rows from the left table and from the right table.
The combines the result of both LEFT and RIGHT joins.
Syntax :-
SELECT columns FROM table1
FULL [OUTER] JOIN table2
on table1.column = table2.column;
Example :-
SQL Inner Join :-
Select all rows from tables for the match between the columns in tables.
Same as JOIN
Syntax :-
SELECT column FROM table1
INNER JOIN table2
on table1.column = table2.column;
[only matching rows are retrieved]
Example :-
SELECT emp.eno, emp.ename, dept.dno, dept.dname FROM emp
INNER JOIN dept
on emp.dno = dept.dno;
SQL LEFT JOIN :-
Returns all rows from the left table, with the matching rows in the right table.
The result is NULL in the right side when there is no match.
Syntax :-
SELECT Columns FROM table1
LEFT [OUTER] JOIN table2
on table1.column = table2.column;
Example :-
SELECT emp.eno, emp.ename,dept.dno, dept.dname FROM emp
LEFT JOIN dept
on emp dno = dept.dno;
SQL RIGHT JOIN :-
Returns all rows from the right table, with the matching rows in the left table.
The result is NULL in the left side when there is no match.
Syntax :-
SELECT columns FROM table1
RIGHT [OUTER] JOIN table2
on table1.column = table2.column;
Example :-
FULL OUTER JOIN
Returns all rows from the left table and from the right table.
The combines the result of both LEFT and RIGHT joins.
Syntax :-
SELECT columns FROM table1
FULL [OUTER] JOIN table2
on table1.column = table2.column;
Example :-
0 Comments:
Post a Comment