select distinct partnerId, partnerType from tbl_TPM_COntracts where ownerId = and ownerType = 'MFR' and partnerType in ( 'OPR', 'CDR' ) update tbl_OPR_CLientOperators set tradeEnabled = 'Y' where ownerId = and fsltablecode = 'MFR' and operatorId = and tradeEnabled is null update tbl_CDR_Distributors set tradeEnabled = 'Y' where ownerId = and fsl_tablecode = 'MFR' and cdr_recordId = and tradeEnabled is null