对编程不是很了解,有个问题。就是
部门表(t1)
deptId deptName
1 研发部
2 市场部
3 客服部
雇员表(t2)
empId empName deptId
1 李华 1
2 王兰 3
写存储过程。输入一个雇员名称,输出雇员所在的部门名称。
怎么写呢。
部门表(t1)
deptId deptName
1 研发部
2 市场部
3 客服部
雇员表(t2)
empId empName deptId
1 李华 1
2 王兰 3
写存储过程。输入一个雇员名称,输出雇员所在的部门名称。
怎么写呢。
as
select a.deptName from t1 a,t2 b where a.deptId=b.deptId and b.empName=@empName
go
@EMPID INT
AS
BEGIN
SELECT
T1.DEPTNAME
FROM T2
LEFT JOIN T1 ON T2.DEPTID=T1.DEPTID
END
GOEXEC PS_TEST 2
as
select dept_name from t1,t2 where t1.deptid=t2.deptid and t2.empid=@empid
as
select a.deptName from t1 a , t2 b where a.deptId=b.deptId and b.empName=@name