create table department
(
dept_id int identity primary key,
dept_name nvarchar(20) not null,
)
select * from department
insert into department
values('Hr')
insert into department
values('Admin')
insert into department
values('Marketing')
insert into department
values('Faculty')
insert into department
values('Managers')
create table employee
(
emp_id int identity primary key,
emp_name nvarchar(20) not null,
emp_salary int,
dem_deptid int foreign key references department(dept_id)
)
insert into employee
values('Ali',40000,3)
insert into employee
values('Ali',30000,1)
insert into employee
values('sami',50000,2)
insert into employee
values('sana',20000,2)
insert into employee
values('kamran',70000,4)
insert into employee
values('sumaira',10000,1)
insert into employee
values('moosa',10000,10)
select * from employee
select * from department
select e.emp_id,e.emp_name,e.emp_salary,d.dept_name,d.dept_id,e.dem_deptid from
employee e inner join department d on d.dept_id=e.dem_deptid
select * from department d inner join employee e on d.dept_id=e.dem_deptid
No comments:
Post a Comment