Is there a way to have one long SQL script find an ID if it exists in a Employees table or a Managers table?
I have a 3rd table called logins which has the persons unique ID.
The employees table has ID | Lastname | Firstname (names in separate columns).
Mangers has ID | Lastname, Firstname | and the managers has both names in one column.
the 3rd table has Unique ID | DateLoggedIN | Wherefrom .
The Wherefrom column contains one of 3 data items "Admin From Managers" , "Manager From Managers"
or "Resource from Resources" a resource is an employee and a manager could have different rights "Admin" or "Manager"
So is there a way to use "case" and have it get the managers name if the Wherefrom contains the word "Managers" or
case when and Select the Lastname , Firstname from the Resources Table if the Wherefrom contains the word "Resources" ?
Select name from ....
Case Wherefrom is substring(1, Wherefrom , "Resources")
Inner join (Select Lastname + ',' + from Firstname as name from Resources on Resources.ID = Logins.ID Where Logins.ID = Wherefrom.ID)
case else
Inner join
Select Manager from Managers on Managers.ID = Logins.ID Where Logins.ID = Wherefrom.ID
...
TIA
DougP
I have a 3rd table called logins which has the persons unique ID.
The employees table has ID | Lastname | Firstname (names in separate columns).
Mangers has ID | Lastname, Firstname | and the managers has both names in one column.
the 3rd table has Unique ID | DateLoggedIN | Wherefrom .
The Wherefrom column contains one of 3 data items "Admin From Managers" , "Manager From Managers"
or "Resource from Resources" a resource is an employee and a manager could have different rights "Admin" or "Manager"
So is there a way to use "case" and have it get the managers name if the Wherefrom contains the word "Managers" or
case when and Select the Lastname , Firstname from the Resources Table if the Wherefrom contains the word "Resources" ?
Select name from ....
Case Wherefrom is substring(1, Wherefrom , "Resources")
Inner join (Select Lastname + ',' + from Firstname as name from Resources on Resources.ID = Logins.ID Where Logins.ID = Wherefrom.ID)
case else
Inner join
Select Manager from Managers on Managers.ID = Logins.ID Where Logins.ID = Wherefrom.ID
...
TIA
DougP