use main

SELECT count(1) FROM TAppSession

DROP TABLE #Mch
 

SELECT A.FMchId ,A.FMchNo INTO #Mch 
FROM TMerchantLoginLog AS B,TMerchantInfo AS A
 WHERE B.FUserType = 'MOBEmployee'
AND B.FTime > '2020-04-30'
AND A.FOwner = 'saidao'
AND A.FMchNo = B.FMchNo
GROUP BY A.FMchId,A.FMchNo

SELECT * FROM #Mch
 
DELETE TMerchantCOnfig
WHERE FMchId IN(SELECT FMchId FROM #Mch)
AND FKey = 'MobileEmployeeAppDisabled'

INSERT TMerchantCOnfig(FMchId,FKey,FValue)
SELECT  FMchId,'MobileEmployeeAppDisabled','true' 
FROM #Mch

SELECT * FROM TMerchantCOnfig WHERE FMchId IN(SELECT FMchId FROM #Mch)
AND FKey = 'MobileEmployeeAppDisabled'



 

AND FMchNo IN(SELECT FMchNo FROM TMerchantInfo WHERE FOwner = 'shanxi')
GROUP BY FMchNo


SELECT * FROM TMerchantCOnfig
WHERE FKey like '%dis%'