Thread: SQL Query
01-14-04, 03:12 #1Registered User
- Join Date
- Jan 2004
Unanswered: SQL Query
I'm using ASP on front end which connects to a database that can be any SQL Server, Access,Oracle so i cannot do anything on the backend. everything i do has to be on front end and it should work for all these databases. the DB connection can be ODBC or OLE DB.
the problem is I have a table that keeps username and managerid. now in this table if i want to pull a manager i need to get records of all the users who report to him or the manager below him.
Like if I have 3 people working under me when someone pulls the ppl working for my manager he should be able to see my information and the ppl who work for me.
Table structure is
[USERLOGONID] [varchar] (30) PK,
[PASSWORD] [varchar] (15) ,
[LASTNAME] [varchar] (30) ,
[FIRSTNAME] [varchar] (15) ,
[MIDDLEINITIAL] [varchar] (1),
[USERID] [int] IDENTITY (1, 1),
[EMPLOYEETYPE] [smallint] ,
[GROUPID] [int] NULL ,
[MANAGERID] [varchar] (30) NULL ,
[JOBCODE] [int] NULL ,
[STATUS] [bit] NOT NULL ,
[HIREDATE] [datetime] NULL ,
[WEBUSEPLUGIN] [smallint] NULL ,
[USERFIELD] [varchar] (50) NULL
The fields that i'm interested in are UserLoginID and ManagerID.
how can i retrieve this information.
01-14-04, 05:43 #2Registered User
- Join Date
- Sep 2003
- The extremely Royal borough of Kensington, London
select t1.ManagerID As LV1_MAN, t1.UserLoginID As LV1_EMP, t2.UserLoginID As LV2_EMP
table t2 ON
t1.ManagerID = x AND
t1.UserLoginID = t2.ManagerID;Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.