sql - select department name query pre-requiste -


i have 3 tables shown below :

courses(     number: integer,      deptname: string,      coursename: string,     classroom: string,      enrollment: integer)  departments(     name: string,      chairmanpid: string)  prereq(     number: integer,      deptname: string,      prereqnumber: integer,     prereqdeptname: string) 

and have find which departments have courses have pre-requisites in other departments?

try this

select d.name,c.coursename, p.deptname       department d      inner join courses c on c.deptname=d.deptname      inner join prereq p on p.prereqdeptname=d.deptname , p.deptname <> d.deptname 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -