Question: Find the name of physicians who are affiliated with both Surgery and Psychiatry departments.
Schema: create table affiliated_with (physician varchar, department varchar, PRIMARY KEY (physician)); create table department (departmentid varchar, name varchar, PRIMARY KEY (departmentid)); create table physician (name varchar, employeeid varchar, PRIMARY KEY (name))
SQL: select t1.name from physician as t1 join affiliated_with as t2 on t1.employeeid = t2.physician join department as t3 on t2.department = t3.departmentid where t3.name = 'surgery' intersect select t1.name from physician as t1 join affiliated_with as t2 on t1.employeeid = t2.physician join department as t3 on t2.department = t3.departmentid where t3.name = 'psychiatry'