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';
精彩评论