join on与where 加and的区别

 

 

create table testA(
  Id number(10) primary key,
  Name varchar(10)
);
insert into testA values(1, '小黄');
insert into testA values(2, '小绿'); 
insert into testA values(3, '小白');
insert into testA values(4, '小黑');
insert into testA values(5, '小花');
commit;

create table testB(
  Id number(10) primary key, 
  age number(10)
);
insert into testB values(1, 10);
insert into testB values(2, 11);
insert into testB values(3, 12);
insert into testB values(4, 13);
commit;

1、join on后面加and


select *
from testA a
  left join testB b on a.id = b.id
  and b.age = 10

join on与where 加and的区别

 

2、where后面加on

select *
from testA a
  left join testB b on a.id = b.id
where 1=1 
and b.age = 10

join on与where 加and的区别

 

 

 

 

 

 

 

 

 

 

上一篇:sql 数据库表如何添加字段-MySQL


下一篇:PS利用Camera Raw的调整画笔工具把荷花图片偏暗部分调亮