软件下载吧文章资讯

分类分类

SQL开发知识:详解sql中exists和in的语法与区别

2024-03-04 00:33作者:下载吧

exists和in的区别很小,几乎可以等价,但是sql优化中往往会注重效率问题,今天咱们就来说说exists和in的区别。
exists语法:
select … from table where exists (子查询)
将主查询的结果,放到子查询结果中进行校验,如子查询有数据,则校验成功,那么符合校验,保留数据。

create table teacher
(
tid int(3),
tname varchar(20),
tcid int(3)
);
insert into teacher values(1,’tz’,1);
insert into teacher values(2,’tw’,2);
insert into teacher values(3,’tl’,3);

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消