UPDATE category c
INNER JOIN
(
SELECT b.category_id FROM category a,
(SELECT * FROM category WHERE del_flag != 'D')b
WHERE a.del_flag = 'D' AND b.parent_id = a.category_id
) d ON c.category_id = d.category_id SET c.del_flag = 'D'
update tableA a inner join tableB b on a.id = b.id set a.name = b.name