HOME

Wednesday, May 11, 2016

SQL PROGRAMS SHOWING THE MAJOR CONCEPTS OF JOINS

joins: combining the columns of two or more tables based on some attributes

types of joins:

cross:-
select * from customer_info1
cross join
order_info1

natural:-
select * from customer_info1
NATURAL join
order_info1


inner:-
returns rows when there is a match in both tables.

SELECT * FROM CUSTOMER_INFO1,ORDER_INFO1
WHERE CUSTOMER_INFO1.C_ID=ORDER_INFO1.C_ID

outer :-
 right outer:-
returns all rows from the right table, even if there are
no matches in the left table.

select * from customer_info1 right outer join order_info1
on customer_info1.c_id=order_info1.c_id

left outer:-
returns all rows from the left table, even if there are
 no matches in the right table.

select * from customer_info1 left outer join order_info1
on customer_info1.c_id=order_info1.c_id

full outer:-
 returns rows when there is a match in one of the tables.

select * from customer_info1 full outer join order_info1
on customer_info1.c_id=order_info1.c_id