Skip to content

Instantly share code, notes, and snippets.

@blakewrege
Created October 8, 2014 08:19
Show Gist options
  • Save blakewrege/cef543f752225ad92687 to your computer and use it in GitHub Desktop.
Save blakewrege/cef543f752225ad92687 to your computer and use it in GitHub Desktop.
SELECT * from (enrolled left join class
on enrolled.cname=class.cname)
union
SELECT * from (enrolled right join class
on enrolled.cname=class.cname);
SELECT *from (class left join faculty
on class.fid=faculty.fid)
union
SELECT * from (class right join faculty
on class.fid=faculty.fid);
@blakewrege
Copy link
Author

This is crazy:
SELECT *
FROM (((student
left join enrolled
on student.snum=enrolled.snum)
left join class
on enrolled.cname=class.cname)
left join faculty
on class.fid=faculty.fid)
union
select *
FROM (((student
right join enrolled
on student.snum=enrolled.snum)
right join class
on enrolled.cname=class.cname)
right join faculty
on class.fid=faculty.fid);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment