"单行子查询返回多行"三桌

时间:2014-04-24 21:04:30

标签: oracle oracle11g oracle-sqldeveloper

将工资核算数据输入列时出现问题。

表AA

ID_USER      PERIOD          SALARY          

1001        1-MAY-2012         ?
1002        1-MAY-2012         ?
1001        1-JUN-2012         ?
1002        1-JUN-2012         ?

表BB

  ID_USER      Name          ID_SALARY           

1001        Rayker          1
1002        Jones           2
1003        Wiliam          2

表CC

    ID_SALARY    SALARY             

  1          $50          
  2          $60 

这是我的脚本:


UPDATE "AA" A 
SET A.SALARY = (select C.SALARY from "BB" B,"CC" C where B.ID_SALARY=C.ID_SALARY)
WHERE EXISTS( SELECT B.ID_USER FROM "AA" A, "BB" B  WHERE A.ID_USER = B.ID_USER )
ORDER BY A.ID_USER

1 个答案:

答案 0 :(得分:0)

这一定就够了

UPDATE "AA" A 
SET A.SALARY = (select C.SALARY from "BB" B,"CC" C where B.ID_SALARY=C.ID_SALARY AND B.ID_USER = A.ID_USER)