mysql - How to return all rows that exists in each group? -


edit: this database. question is:

find course title students whom advisor professor katz took course.

what thought solve question:

1) find id of prof. katz.

2) using id, find ids of students whom prof. katz advises.

3) using founded student ids, find courses prof. katz's advisees took.

4) group result student ids , rows present in each group, hence finding course taken all advisees of prof. katz.

i couldn't perform step 4.


how return rows grouped table, each returned row exists in every group of table?

select title  course inner join takes    on course.course_id = takes.course_id  takes.id in  (select student.id   student inner join advisor on students.id = advisor.s_id     inner join instructor on advisor.i_id = instructor.id   instructor.name = 'prof.katz' ) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -