Monday, January 29, 2024

What is Inner Join?

INNER JOIN selects records that have matching values in both tables as
It returns the combination of all rows from both tables based on a related column.


 

Example 

Table_1

create table Table_1 (A varchar);
Insert into Table_1 (A)
values ('x'),('x'),('z'),('0'),('null');


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 for Inner Join


SELECT table1.column1, table1.column2, table2.column1,....
FROM table1
LEFT JOIN table2ON table1.matching_column = table2.matching_column;

--Inner join--

select *from Table_1 T1
join Table_2 T2
on T1.A=T2.A;



No comments:

Post a Comment