Thursday, February 1, 2024

What is Full Join?

In SQL, FULL JOIN is the result of a combination of inner join, left join, and right join. Join tables have all the records from both tables. It puts NULL in the place of matches not found.




Example

Table_1

create table Table_1 (A varchar);

Insert into Table_1 (A)

values ('x'),('x'),('z'),('0');


select * from Table_1;


Table_2

create table Table_2 (A varchar);

Insert into Table_2 (A)

values ('y'),('x'),('0'),('x');

 

select * from Table_2;


Syntax 

SELECT table1.column1, table1.column2, table2.column1,....
FROM table1 RIGHT JOIN table2 
ON table1.matching_column = table2.matching_column;


Query for Full Join

--Full Join--

select *from Table_1 T1

full join Table_2 T2

on T1.A=T2.A;






























No comments:

Post a Comment