Open DevShivmohan opened 2 years ago
Join multiple table at a time
SELECT customerName, customercity, customermail, ordertotal,salestotal
FROM onlinecustomers AS c
INNER JOIN
orders AS o
ON c.customerid = o.customerid
LEFT JOIN
sales AS s
ON o.orderId = s.orderId
WHERE s.salesId IS NULL
select * from user_master as um join user_role_map as urm on um.user_id=urm.user_id
+.....+where urm.role_id=5;
Equi join = Natural join = Inner join
these are same equality;
Natural join syntax
select * from <table_name1> natural join <table_name2>;
Inner join syntax
select * from <table_name1> inner join <table_name2> on <table_name1>.<column_name>=<table_name2>.<column_name>;
Cross join syntax
select * from <table_name1> cross join <table_name2>;
If we have two tables every table has 5 records then result of cross join *55** [25] records;
Left outer join
select * from <table_name1> left outer join <table_name2> on <table_name1>.<column_name>=<table_name2>.<column_name>;
Right outer join
select * from <table_name1> right outer join <table_name2> on <table_name1>.<column_name>=<table_name2>.<column_name>;
Full outer join
select * from <table_name1> full outer join <table_name2> on <table_name1>.<column_name>=<table_name2>.<column_name>;
All join operations perform between these two tables personal and professional
Syntax- SELECT column_list
FROM table1, table2.... WHERE table1.column_name = table2.column_name;
Example- SELECT personal.id,personal.name,professional.dept,professional.work FROM personal,professional WHERE personal.id=professional.id;
OR
Syntax- SELECT column_list FROM table1
JOIN table2 [ON (join_condition)]
Example- SELECT personal.name,personal.address,professional.dept,professional.work FROM personal JOIN professional ON personal.id=professional.id;
Syntax- SELECT *
FROM table_name1, table_name2
WHERE table_name1.column [> | < | >= | <= ] table_name2.column;
Example- SELECT * FROM personal,professional WHERE personal.id < professional.id;
In this query personal.id less then professional.id that record are joined