If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-14-04, 02:12
mtaimoor mtaimoor is offline
Registered User
 
Join Date: Jan 2004
Posts: 1
Exclamation 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.
Reply With Quote
  #2 (permalink)  
Old 01-14-04, 04:43
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
select t1.ManagerID As LV1_MAN, t1.UserLoginID As LV1_EMP, t2.UserLoginID As LV2_EMP
from
table t1
INNER JOIN
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On