select c.name,c.modify_emp_id,d.name from client c,emp e,dept d where c.modify_emp_id=e.emp_id and e.dept_id=d.dept_id;不作表连接的根本取不到部门的信息。即使使用函数也是在函数内部使用表连接的
"同一张表里的由一个字段得到另一个字段我想会不会有一个公共函数啊" ——ORACLE没有这种函数。我想DEPT()不应该是你写的这样子的。 create or replace function dept(empid in varchar2) return varchar2 is deptid varchar2(200); begin select dept_id into deptid from emp where emp_id=empid; return deptid; end;上面做表连接也不错,为什么不想做表连接呢?
to : nottinghill这个应该满足你的要求了吧,速度应该是最快的了哦 :)select name ,modify_emp_id, (select name from emp where emp_id = modify_emp_id) emp_name from client
hehe,好强啊,说说运行机制啊 ,我给你分
select name ,modify_emp_id, (select name from emp where emp_id = modify_emp_id) emp_name from client 这不还是表连接吗,只是换个写法
hehe ,我也知道是朝三暮四,但我可以实现就可以了,这样写至少 from 后面是统一的,好操作!!谢谢各位大侠指点啊我还知道 这能实现是为什么啊??
where c.modify_emp_id=e.emp_id and e.dept_id=d.dept_id;不作表连接的根本取不到部门的信息。即使使用函数也是在函数内部使用表连接的
——ORACLE没有这种函数。我想DEPT()不应该是你写的这样子的。
create or replace function dept(empid in varchar2) return varchar2
is
deptid varchar2(200);
begin
select dept_id into deptid from emp where emp_id=empid;
return deptid;
end;上面做表连接也不错,为什么不想做表连接呢?
(select name from emp where emp_id = modify_emp_id) emp_name from client
(select name from emp where emp_id = modify_emp_id) emp_name from client
这不还是表连接吗,只是换个写法