Code&Data Insights

[MySQL] Inner Join | Left Join | Right Join | Self Join 본문

Computer Science/Databases

[MySQL] Inner Join | Left Join | Right Join | Self Join

paka_corn 2023. 2. 8. 05:53

Inner Join 

: selects records that have matching values in both tables. 

=> intersection of two tables 

 

 

< Syntax > 

SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;

 

 

Left Join

 

 

< Syntax > 

SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;

 

 

 

Right Join 

 

 

< Syntax > 

SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;

 

 

Self Join 

- a regular join, but the table is joined with itself.

 

 

< Syntax > 

SELECT column_name(s)
FROM table1 T1, table1 T2
WHERE condition;

 

Comments