UPDATE t_bd_materialinvinfo t10 SET fisoutputrequest=(
SELECT  0 FROM (
SELECT t2.fid,t1.fenableserial,t1.fisoutputrequest  FROM t_bd_material_s t1 INNER JOIN t_bd_materialinvinfo t2 ON t2.fmasterid=t1.fid 
  ) t11
 WHERE t10.fid=t11.fid and  t11.fenableserial= 1 and t11.fisoutputrequest = 1  and t10.fisoutputrequest =0) where 
 EXISTS(SELECT t11.fisoutputrequest FROM (
SELECT t2.fid,t1.fenableserial,t1.fisoutputrequest  FROM t_bd_material_s t1 INNER JOIN t_bd_materialinvinfo t2 ON t2.fmasterid=t1.fid 
  ) t11
 WHERE t10.fid=t11.fid and  t11.fenableserial= 1 and t11.fisoutputrequest = 1 and t10.fisoutputrequest =0);
 
 
 UPDATE t_bd_materialinvinfo t10 SET fisoutputrequest=(
SELECT  1 FROM (
SELECT  t2.fid,t1.fenableserial,t1.fisoutputrequest  FROM t_bd_material_s t1 INNER JOIN t_bd_materialinvinfo t2 ON t2.fmasterid=t1.fid 
  ) t11
 WHERE t10.fid=t11.fid and  t11.fenableserial= 1 and t11.fisoutputrequest = 0 and t10.fisoutputrequest =0) where 
 EXISTS(SELECT t11.fisoutputrequest FROM (
SELECT t2.fid,t1.fenableserial,t1.fisoutputrequest  FROM t_bd_material_s t1 INNER JOIN t_bd_materialinvinfo t2 ON t2.fmasterid=t1.fid 
  ) t11
 WHERE t10.fid=t11.fid and  t11.fenableserial= 1 and t11.fisoutputrequest = 0 and t10.fisoutputrequest =0);