MySQL Forums
Forum List  »  Views

Create a View to show Staff and employees together
Posted by: Gary Newt
Date: May 27, 2011 01:47AM

I'm trying to create a view which uses the same table fields twice - I want to have a view showing the Managers Name and Phone, and the Employees name and phone which are in two seperate table, linked to a Person Table which holds the Contact details. When try to do the query it results in the same PersonID being used so i get the Manager details twice, or the employee details twice.

If you can give me some ideas on how to do this... t think i have to use a copy of the Person Table or somethink?

Table Person
PersonID PK
Name
Phone

Table Employee
PersonID PK,
Manager FK
Wages..

Table Manager
PersonID PK,
Salary..


select Person.Name,Person.Phone, Person.Name,Person.Phone
FROM Employee Join Person
ON Employee.Person_ID = Person.Person_ID
Join Staff
ON Staff.Person_ID = Person.Person_ID;



G



Edited 2 time(s). Last edit at 05/27/2011 10:16PM by Gary Newt.

Options: ReplyQuote


Subject
Views
Written By
Posted
Create a View to show Staff and employees together
2511
May 27, 2011 01:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.