简体   繁体   English

更新表内部联接

[英]Update table inner join

I have two tables and i need to update one of them with respect to the id's of the second table 我有两个表,我需要针对第二个表的ID更新其中之一

first table successlog ; 第一表成功日志 ;

Id     pid      shiftid
1       2          
2       2          
3       2          
4       5          
5       5
6       6
7       6   

second table employeelist ; 第二表员工名单 ;

Id    pId      shiftid
1      2          1
2      5          1
3      6          2

I need to update the first table's shiftid with respect to the pid in the two tables. 我需要相对于两个表中的pid更新第一个表的shiftid

I'm using the below query but its not working; 我正在使用以下查询,但无法正常工作;

        $sql1="UPDATE successlog
                SET successlog.shiftid = employeelist.shiftid
                 FROM successlog
                 INNER JOIN employeelist
                 ON successlog.pid=employeelist.pId";  

You statement must look like this: 您的声明必须如下所示:

$sql1="UPDATE successlog INNER JOIN employeelist  ON successlog.pid=employeelist.pId
            SET successlog.shiftid = employeelist.shiftid";  
UPDATE successlog 
INNER JOIN employeelist
ON successlog.pid=employeelist.pId 
SET successlog.shiftid = employeelist.shiftid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM