SELECT * FROM TConsumeItem WHERE FDeptId NOT IN(SELECT FId FROM TBasicType) OR FDeptId = 0 SELECT * FROM TConsumeGoods WHERE FDeptId NOT IN(SELECT FId FROM TBasicType)OR FDeptId = 0 SELECT * FROM TMemberSaleCourse WHERE FDeptId NOT IN(SELECT FId FROM TBasicType)OR FDeptId = 0 SELECT * FROM TMemberSaleCard WHERE FDeptId NOT IN(SELECT FId FROM TBasicType)OR FDeptId = 0 SELECT * FROM TMemberSaleCoursePack WHERE FDeptId NOT IN(SELECT FId FROM TBasicType)OR FDeptId = 0 SELECT * FROM TConsumeItem WHERE SELECT * FROM TEmployee WHERE FDeptId NOT IN (SELECT FId FROM TBasicType) SELECT * FROM TItem WHERE FDeptId NOT IN (SELECT FId FROM TBasicType) SELECT * FROM TGoods WHERE FDeptId NOT IN (SELECT FId FROM TBasicType) UPDATE B SET B.FDeptId = A.FDeptId FROM TConsumeItem AS B,TItem AS A WHERE A.FId = B.FItemId UPDATE B SET B.FDeptId = A.FDeptId FROM TMemberSaleCourse AS B,TItem AS A WHERE A.FId = B.FItemId UPDATE B SET B.FDeptId = A.FDeptId FROM TMemberSaleCard AS B,TMemberCardType AS A WHERE A.FId = B.FCardTypeId UPDATE B SET B.FDeptId = A.FDeptId FROM TConsumeGoods AS B,TGoods AS A WHERE A.FId = B.FGoodsId