Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you query 3 tables

Status
Not open for further replies.

dunskii

Programmer
Sep 14, 2001
107
AU
Hi,

I'm trying do a list of employees which shows their name and then lists their areas of practice.

I have a employees table, an areas of practice table and one that has the employee id with corosponding area id.

What is the best way to query the three tables then list the employees with their areas of practice listed next to them.

Thanks in advance,

Dunskii
 
Hello Dunskii,

There are two possibilities to get the result. One is with using the join clause to connect the tables with each other. The other one is connecting them in the where clause.

1. The join clause:
SELECT employee.name, area.practice
FROM employee INNER JOIN (area INNER JOIN emp_area ON area.practiceID = emp_area.practiceID) ON employee.employeeID = emp_area.employeeID

2. The where clause:
SELECT employee.name, area.practice
FROM employee, area, emp_area
WHERE (emloyee.employeeId = emp_area.employeeId) and (emp_area.practiceId = area.practiceId)


Charl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top