How to show Name and ID number

  • Thread starter Thread starter John K
  • Start date Start date
J

John K

I have an employee table that I am trying to use to
relate to a project table. I have a query that I am
trying to use to output the employee name from the
project table how do I display the name of the employee
and the employee ID?
 
John K said:
I have an employee table that I am trying to use to
relate to a project table. I have a query that I am
trying to use to output the employee name from the
project table how do I display the name of the employee
and the employee ID?


John K,

Assuming the following:

CREATE TABLE Employees
(EmployeeID AUTOINCREMENT
,NameFirst TEXT(72)
,CONSTRAINT pk_Employees PRIMARY KEY (EmployeeID)
)

CREATE TABLE Projects
(ProjectID AUTOINCREMENT
,EmployeeID LONG
,CONSTRAINT pk_Projects PRIMARY KEY (ProjectID)
,CONSTRAINT fk_Employees_Employees FOREIGN KEY (EmployeeID)
REFERENCES Employees (EmployeeID)
)


It should be something like:

SELECT P1.EmployeeID
,E1.EmployeeName
FROM Projects AS P1
INNER JOIN
Employees AS E1
ON P1.Employee = E1.Employee;


(That's untested.)


Sincerely,

Chris O.
 
Back
Top