Re: JOINing the same table

From: Wally (sgb_paul_at_yahoo.com)
Date: 02/07/05


Date: 7 Feb 2005 14:58:41 -0800


Query Builder wrote:
> Are you saying you have a primary key that is been referenced as a
> foreignkey in the same table? WHYyyyy?? Anyways, to solve your
problem
> for now, here is the query......

No... there is no actual reference between the fields. As far as SQL
Server is concerned, pk_SupervisorID is an indexed primary key......
and fk_SupervisorID is just another unreferenced column with data in
it. The relation of the two fields only occurs in reports that the
front-end calls for.

> select E.LastName as EmpLastName,
> (Select LastName as SupLastName from Employees
> Where employeeID = E.SupervisorID)
> from Employee E

FYI: Your SELECT statement worked fine, but for some odd reason it
didn't label the SupLastName field.

Thanks!



Relevant Pages

  • Re: Employee hrs worked
    ... just have a Categories table and reference this from ... Projects are an entirely different entity type so use a separate Projects ... ProjectName (SubCategory) ... attributes of the entity type in question, e.g. Employees is an entity type ...
    (microsoft.public.access.gettingstarted)
  • Re: Q on designing and relating these 2 tables
    ... Autonumber field and designate it as primary key. ... i'm not sure i'd include ScheduledHours in this table, ... table EMPLOYEES describes each employee, ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Q on designing and relating these 2 tables
    ... CEV, sorry to be so long, just got back to this thread. ... > I have one question though with the EmplPosID (Primary Key) field. ... >> table EMPLOYEES describes each employee, ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Autonumber Fields
    ... What would you do to guarantee uniqueness in a Contacts table or some such ... I have a database that includes an Employees table. ... > Clustered Index can only be a Primary Key. ... >> Suppose I wanted to create a clustered index in an Access table. ...
    (microsoft.public.access.tablesdbdesign)
  • RE: How to automatically update data in form based on results of e
    ... is with the structure of your employees table. ... The foreign key field in the termination entry is "Name" ... The primary key in the Employees table is "Name" ...
    (microsoft.public.access.formscoding)