我想使用SELECT对表中的某些字段执行UPDATE

时间:2012-10-17 12:00:41

标签: mysql

//这是我试图编译的整个查询

//下面是有错误的代码。我无法弄明白。

//查询开始

//错误:从“UPDATE d FROM ....”开始,这个语法是否正确?

UPDATE d FROM Deployment d INNER JOIN Employment e ON d.employment_id = e.employment_id where e.consultant_id=14
   SET d.date_end = '2012-10-17',
       d.updated_by = 4,
       d.updated_date = SYSDATE()
 WHERE e.consultant_id = 14
   AND date_end IS NULL;

//代码在这里结束

1 个答案:

答案 0 :(得分:2)

UPDATE Deployment d 
INNER JOIN Employment e ON d.employment_id = e.employment_id SET d.date_end = p_date_e`nd, 
d.updated_by = p_loggedin_user_id, d.updated_date = SYSDATE() 
WHERE e.consultant_id = p_consultant_id
AND d.date_end IS NULL;