Last active
September 29, 2021 20:44
-
-
Save avbelyaev/d86f6a34cadc339ef4dfbb2d2080d156 to your computer and use it in GitHub Desktop.
TP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- create table tmp2( | |
-- foo int | |
-- ) | |
-- insert into tmp values (1),(2),(4),(4),(5),(null); | |
-- insert into tmp2 values (1),(3),(4),(4),(5),(5),(null); | |
-- select tmp.foo, tmp2.foo | |
-- from tmp | |
-- inner join tmp2 on tmp.foo = tmp2.foo | |
-- create table emp( | |
-- id int, | |
-- chef_id int, | |
-- dept int | |
-- ); | |
-- insert into emp values | |
-- (1,null,1), | |
-- (2,1,1), | |
-- (3,1,2), | |
-- (4,2,3), | |
-- (5,3,1), | |
-- (6,1,2); | |
-- select * | |
-- from emp a | |
-- left join emp b on b.id = a.chef_id and b.dept = a.dept | |
-- where b.id is null | |
-- select * | |
-- from emp a | |
-- left join emp b on b.id = a.chef_id | |
-- where b.id is not null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment