sql语句.
1.select a.* from A a left join B b on a.id =b.id and a.id=2; 2.select a.* from A a left join B b on a.id =b.id where a.id=2;
这两个sql语句有什么区别?
解决方法
create table A(id int); create table B(id int); INSERT INTO A VALUES(1); INSERT INTO A VALUES(2); INSERT INTO A VALUES(3); INSERT INTO B VALUES(1); INSERT INTO B VALUES(2); INSERT INTO B VALUES(3); SELECT * FROM A; SELECT * FROM B; id ----------- 1 2 3 id ----------- 1 2 3
过滤JOIN以防止在JOIN进程期间添加行.
select a.*,b.* from A a left join B b on a.id =b.id and a.id=2; id id ----------- ----------- 1 NULL 2 2 3 NULL
JOIN发生后,将过滤.
select a.*,b.* from A a left join B b on a.id =b.id where a.id=2; id id ----------- ----------- 2 2