Hi
Please refer below article-
If you want to show data In below formate
chetan says:
Empname address designation Department
refer query
SQL
DECLARE @employee AS TABLE(id int,name varchar(20),address varchar(100),designation varchar(20),department int)
INSERT INTO @employee VALUES(1,'Mudassar Ahmed Khan', 'India','Software Engineer', 1)
INSERT INTO @employee VALUES(2,'John Hammond', 'USA','Software Engineer', 3)
INSERT INTO @employee VALUES(3,'Suzanne Mathews', 'France','Software Engineer', 2)
DECLARE @department AS TABLE(did int,department varchar(20))
INSERT INTO @department VALUES(1,'IT')
INSERT INTO @department VALUES(2,'CS')
INSERT INTO @department VALUES(3,'Biology')
SELECT id, name, designation, d.department FROM @employee e
INNER JOIN @department d ON d.did=e.department
Output
id |
name |
designation |
department |
1 |
Mudassar Ahmed Khan |
Software Engineer |
IT |
2 |
John Hammond |
Software Engineer |
Biology |
3 |
Suzanne Mathews |
Software Engineer |
CS |