1

好吧,不幸的是,我搜索了很多不同的地方,问起来可能更容易,

我必须选择一些数据,然后将工资设置为增加 10%,而我的标准在另一张表上,这是我的代码

 Select E.Lastname, E.Salary, J.EEO1Classification from Employee as E
 Join JobTitle as J
 on E.JobTitleID = J.JobTitleID 
 Update Employee
 set Salary = (Salary * .10) + Salary
 where [JobTitle.EEO1Classification] = 'Office/Clerical'

我哪里错了?

4

2 回答 2

2
UPDATE Employee e
SET e.Salary = e.Salary * 1.1
WHERE e.JobTitleID IN 
( SELECT j.JobTitleID FROM JobTitle j 
        WHERE j.EEO1Classification = 'Office/Clerical'
)
于 2012-09-14T04:08:39.923 回答
0

我认为这就是您可能想要实现的目标。基本上是UPDATE使用表JOINJobTitle

MySQL

UPDATE Employee E
INNER JOIN JobTitle as J
  ON E.JobTitleID = J.JobTitleID 
SET Salary = (Salary * .10) + Salary
WHERE [J.EEO1Classification] = 'Office/Clerical'

替代语法

UPDATE
    e
SET
    Salary = (Salary * .10) + Salary
FROM
    Employee E
    JOIN
    JobTitle J ON E.JobTitleID = J.JobTitleID 
WHERE
    J.EEO1Classification = 'Office/Clerical'
于 2012-09-14T03:58:10.463 回答