开发者

how to perform delete operation fro two mysql databases using mysql inner join

开发者 https://www.devze.com 2023-04-04 11:26 出处:网络
I have two 开发者_Python百科mysql database. I need to delete a row of table from one database by joining two data bases. I used the following query.

I have two 开发者_Python百科mysql database. I need to delete a row of table from one database by joining two data bases. I used the following query.

delete from operations
where operationid=( 
 select distinct(r.operationid) 
 from focuscareer02.careeroperations c 
 inner join fcuserreport.operations r 
 on c.careeroperation='clearresume' and c.careeroperationid=r.operationid
) and breakup='daily';

But I got the error like "you can't specify target table 'operations for update in from clause'".


Use WHERE ... IN, rather than WHERE ... =:

delete from operations
where operationid IN ( 
    select distinct(r.operationid) 
    from focuscareer02.careeroperations c 
    inner join focuserreport.operations r 
        on c.careeroperation='clearresume'
        and c.careeroperationid=r.operationid
) and breakup='daily';
0

精彩评论

暂无评论...
验证码 换一张
取 消