delete from t_perm_rolepermdetial where fid not in(select distinct fid from t_perm_roleperm);

UPDATE t_perm_rolepermdetial a SET froleid =
(
SELECT b.froleid
FROM t_perm_roleperm b
where b.fid = a.fid
)
where exists (
SELECT b.froleid
FROM t_perm_roleperm b
where b.fid = a.fid
);