Sunscreen
Sunscreen

Reputation: 3564

Is there a way to have two columns in a table having linked to the same reference table?

New to designing databases. I currently try to create a database in MS Access.

The two tables I need are:

Can I link the EMPLOYEE with the PEOPLE.ID and SUPERVISOR again with PEOPLE.ID?

Does it make sense? I am asking because Access created a duplicate PEOPLE_1 table to link the second column.

Thanks,

Upvotes: 0

Views: 46

Answers (1)

Dorian
Dorian

Reputation: 445

Yes. The way Access made it, works. You need the PEOPLE table twice, so you can reference two different records (the employee and the supervisor) at the same time.

If you want, you can also set an alias for both PEOPLE tables. Example:

SELECT COMPANY.ID, emp.NAME, sup.NAME
FROM COMPANY LEFT JOIN PEOPLE AS emp ON COMPANY.EMPLOYEE = emp.ID
LEFT JOIN PEOPLE AS sup ON COMPANY.SUPERVISOR = sup.ID

(I didn't use Access for quite a long time. Maybe you have to put brackets around one of the join statements to make it work)

Upvotes: 1

Related Questions