常见SQL关联查询

1. inner join 内连接查询

SELECT a.*,b.* FROM table_a a INNER JOIN table_b b ON a.id=b.id;

2. left join 左关联查询

SELECT a.*,b.* FROM table_a a LEFT JOIN table_b b ON a.id=b.id;

3.right join 右关联查询

SELECT a.*,b.* FROM table_a a RIGHT JOIN table_b b ON a.id=b.id;

4.左连接-内连接

SELECT a.*,b.* FROM table_a a LEFT JOIN table_b b ON a.id=b.id WHERE b.id IS NULL;

5. 右连接-内连接

SELECT a.*,b.* FROM table_a a RIGHT JOIN table_b b ON a.id=b.id WHERE a.id IS NULL

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章