use main INSERT TMerchantConfig(FMchId,FKey,FValue) SELECT dbo.FNClientId(FClientNo),'MobileEmployeeAppDisabled','false' FROM TClientLoginLog WHERE FTime > '2018-11-01' AND FUserType = 'MOBEmployee' AND FMessage = 'µÇ½³É¹¦' GROUP BY FClientNO UPDATE TMerchantConfig SET FValue = 'true' WHERE FKey = 'MobileEmployeeAppDisabled' AND FMchId IN(SELECT C.FClientId FROM TClientInfo AS C WHERE FClientNo IN( SELECT FClientNo FROM ( SELECT FClientNO ,SUM(1) AS FCount FROM TClientLoginLog WHERE FTime > '2018-11-18' AND FUserType = 'MOBEmployee' AND FMessage = 'µÇ½³É¹¦' --AND FClientNo IN(SELECT FClientNo FROM TClientInfo WHERE FOwner = 'shanxi') GROUP BY FClientNO -- ORDER BY SUM(1) ASC ) AS A WHERE A.FCount <= 100 )) AND FValue = 'false' use saidao_main SELECT * FROM TClientLoginLog WHERE FMessage like '%app%' AND FTime > '2018-11-01' SELECT * FROM TClientInfo WHERE FClientNO = '0715xha' PGetConnInfo '0715XHA' SELECT * FROM TClientInfo WHERE FClientNO = '0715XHA' SELECT * FROM TServerInfo WHERE FServerId = 104 SELECT * FROM TClientLoginLog WHERE 1=1 --AND FClientNO = '0715xha' AND FTime > '2018-11-13' AND FUserType = 'MOBEmployee' ORDER BY FTime DESC