Android Question How to Use UNION ALL SQL COMMAND

manuaaa

Member
Licensed User
Longtime User
Hi All,

I had a MSSQL Query. Iam using this query to get hierarchy of a manager level employee (i means to say that Name of a manager and all employees reporting to him till end)

In MSSQL I had a table name 'FS6' with details of employees, columns using in this table are

FSID ---------(using it as Employee ID)
Name---------(Using it as 'Name of the Employee')
Designation --(Using it as 'Designation of Employee')
RPTO----------(using it as 'Employee Reporting To')
RPTOID--------(using it as ID of Employee Reporting To column')

I am using the below mentioned query successfully in MSSQL to get the hierarchy of a manager whose FSID is 384

WITH Employeelist as
(SELECT boss.fsid, boss.Name, boss.designation, boss.RPTO, 1 as EmpLevel from FS6 as boss where boss.fsid = 384
UNION ALL
SELECT emp.fsid, emp.Name, emp.designation, emp.RPTO, EL.EmpLevel + 1 from FS6 as emp INNER JOIN Employeelist AS EL ON emp.RPTOID = EL.FSID where emp.RPTOID IS NOT NULL)
SELECT * FROM Employeelist


now i wants to use the same sql query to fetch all employees names and fsid under manager having fsid 384 in a listview on a button click

Is there anybody who knows how ......how to do it?
 

Attachments

  • mssql.png
    mssql.png
    167.2 KB · Views: 183
Last edited:
Top