時間:2024-03-04 00:33作者:下載吧人氣:23
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);
網友評論