1

我有两张桌子..

人员:

  empid(primary key)
  firstname
  lastname
  email

细节:

  Did(primary key)
  salary
  designation
  empid

现在我需要更新名称为“abc”且名称为经理的员工的电子邮件。(假设有多个员工名称为 abc,因此需要检查名称)我使用的是 sql server 2008

4

2 回答 2

7
UPDATE p
  SET email = 'newemail@wherever.com'
  FROM dbo.Persons AS p
  INNER JOIN dbo.Details AS d
  ON p.empid = d.empid
  WHERE p.firstname = 'abc'
  AND d.Designation = 'manager';
于 2012-08-28T16:45:53.977 回答
0

尝试这个:

UPDATE 
  [Persons] 
SET 
  [Persons].[email]='###@###.###'
FROM 
  [Persons] 
  INNER JOIN [Persons].[empid] 
  ON [Details].[empid] = [Persons].[empid] 
WHERE 
  [Persons].[firstname]='abc' AND 
  [Details].[designation]='Manager'
于 2012-08-28T16:56:19.187 回答