Anti join in mysql

create table tab_tset1 (id INT, PRIMARY KEY(id));
create table tab_test2(id INT);
insert into tab_test1 values (1), (2), (3), (4);
insert into tab_test2 values (1), (2);

select from tab_test1 t1
where not in (select from tab_test2 t2);

select from tab_Test1 t1
where not exists
(select 1 from tab_tetst2 t2 where;

from tab_test1 t1
left outer join tab_test2 t2 on
where is null;

choose one thing that you want

if there are a lot of datas i prefer to use third way


Popular posts from this blog

codefights smooth sailing ( CommonCharacterCount)

How to remove 8443 port in URL in tomcat