Skip to content
Advertisement

How to display a list of departments whose teachers teach DBMS department students?

I have a database in Access. The database has 4 tables:

[DEPARTMENT]1, [TEACHER]2, [LECTURE]3, [SGROUP]4.

I need to display a list of departments whose teachers teach DBMS department students.

The question is: how to do it? I think it should be a query to join multiple times on the same table … but I don’t understand which table to join …

I’m a noob.

Advertisement

Answer

First, you need to add DepNo value which 3, so the concatenation logically works

INNER JOIN displays everything you want about;

departments whose teachers teach DBMS department students

SELECT DEPARTMENT.DepNo, TEACHER.TechNo, TEACHER.name, DEPARTMENT.name, TEACHER.post
FROM DEPARTMENT
INNER JOIN TEACHER ON DEPARTMENT.DepNo=TEACHER.DepNo
ORDER BY TEACHER.name;

Image chart for What’s the INNER JOIN:

Reference:

SQL Joins

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement