Vagabond
Vagabond

Reputation: 581

Querying from two tables in Oracle Database

I have two tables where I have students details and other table consists of the details of TAs. Tables are as follows:

Students(B#, first_name, last_name, status, GPA, email, bdate, dept)
TAs(B#, ta_level, office)

Now, For each TA from the CS department, find his/her B#, first name, last name, and birth date. I have tried the following query:

select Students.B#, Students.FIRST_NAME, Students.LAST_NAME, Students.BDATE
from Students INNER JOIN TAs ON Students.B# = TAs.B#;

but I have to get only those TAs who are studying in Computer Science. I am using Oracle DB. How will I add another condition after inner join?

Upvotes: 0

Views: 51

Answers (1)

Moudiz
Moudiz

Reputation: 7377

For each TA from the CS department

Is there a table or a column specify if a student is studying Computer Science ? however as per your question it seems from the department you can know that. You can do the below:

select Students.B#, Students.FIRST_NAME, Students.LAST_NAME, Students.BDATE
from Students INNER JOIN TAs ON Students.B# = TAs.B#
where Students.dept='CS' -- or computer science depending on the value.

Upvotes: 1

Related Questions