test3.emp_id=payroll_item.emp_id应去掉。
解决方案 »
- 请教涉及到两个表比较差异的存储过程怎么写?
- SET @TABLE='COMP'+@ID
- 关于MS SQL Server 2000的Enterprise版和Developer版
- SQL菜鸟问一道SQL面试题目,跪求最佳答案
- RAC数据库出现大量的gc buffer busy等候事件,请教如何解决
- 创建索引时权限不足怎么办?
- Oracle数据库中长字符串用什么?
- 请问在orcale 8i 中用什么字段类型保存年月日时分秒的,急!在线等!!
- 各位,请问在oracle--PL/SQL中执行存储过程是否有类似SQL Server的exec 命令
- 请问各位:如何在AIX下重起0RACLE 的服务?访问ORACLE是通过哪个(共4个)IP?
- 最后30分,求Oracle的存储过程里的Out的用法?
- 登陆数据库的问题
2 set amount=(
3 select personal_tax
4 from test3
5 where test3.emp_id=payroll_item.emp_id) 6 where payroll_item.emp_id in (select emp_id from test3)
7 and payroll_item.item_id='0157'
8 and payroll_item.pay_id=11;
能限制住外面的where test3.emp_id=payroll_item.emp_id这个条件吗??
结果出不来,没有提示
set amount=(
select personal_tax
from test3
where test3.emp_id=payroll_item.emp_id)
where payroll_item.emp_id in (select emp_id from test3)
and payroll_item.item_id='0157'
and payroll_item.pay_id=11;
总共emp_id 300条记录吧
set amount=(
select personal_tax
from test3
where test3.emp_id=payroll_item.emp_id)
where
exist(select * from test3 where payroll_item.emp_id=test3.emp_id ) and payroll_item.item_id='0157'
and payroll_item.pay_id=11;效率高
2 set amount=(
3 select personal_tax
4 from test3
5 where test3.emp_id=payroll_item.emp_id)
6 where exist(select * from test3 where payroll_item.emp_id=test3.emp_id)
7 and payroll_item.item_id='0157'
8 and payroll_item.pay_id=11;
where exist(select * from test3 where payroll_item.emp_id=test3.emp_id)
*
ERROR 位于第 6 行:
ORA-00936: missing expression
exist -----> EXISTS
子查询
select A(
select B
(
set amount=(
select personal_tax
from test3
where test3.emp_id=payroll_item.emp_id)
where exists (select * from test3 where test3.emp_id=payroll_item.emp_id)
and payroll_item.item_id='0157'
and payroll_item.pay_id=11;这里是该没问题的,但是结果没出来,不知道怎么回事情?
父查询的表可引用到子查询
但是子查询的表不可引用到父查询