need help to generate SQL query

Akshay C

there are two tables Employee and Department

Employee table

 EmpID  EmpName
 E001   Jack
 E002   Jill

Department table

DeptID  DeptName
D001    IT
D002    HR

Result

ID     Name      Type
E001    Jack    Employee
E002    Jill    Employee
D001    IT      Department
D002    HR      Department

how to add that third column?

Jens

use fix values:

select EMPID, EMPNAME, 'Employee' as TYPE from Employee 
Union all
select DeptID  , DeptName, 'Department'  as TYPE from Department 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related