左连接
left join -- 返回左表中所有的数据以及右表中字段相同字段的值
两张表查询语句:
SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name = table2.column_name;
多表查询语句:
SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name = table2.column_name LEFT JOIN table2 ON table2.column_name = table3.column_name;
右连接
right join -- 返回右表中所有的数据以及左表中字段中相同字段的值
两张表查询语句:
SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column_name;
多表查询语句:
SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column_name
RIGHT JOIN table2 ON table2.column_name = table3.column_name;
内连接
inner join -- 返回左右两个表中字段相同的数据值
两张表查询语句:
SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name = table2.column_name;
多表查询语句:
SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name = table2.column_name INNER JOIN table2 ON table2.column_name = table3.column_name;
标签:table2,table1,JOIN,name,区别,column,连接,SELECT From: https://www.cnblogs.com/handaxing/p/17113674.html