USE MainDatabase

UPDATE tbGrOper SET ESCFPriznak=0 WHERE idGrOper in 
(SELECT tbGrOper.idGrOper FROM tbDeist
LEFT JOIN tbDeist tbDeist2 ON tbDeist2.idDeistPar = tbDeist.idNameDeist
LEFT JOIN tbGrOper ON tbGrOper.idNameDeist = tbDeist2.idNameDeist
WHERE tbDeist2.idDeistPar IS NOT NULL AND tbDeist2.NameDeist LIKE '%Приход%')
