select distinct t1.siteid, t1.tenterprise_userid
from tenterprise_users t1
         left join tauthgroup t2 on t1.siteid = t2.siteid and t1.tauthgroupid = t2.tauthgroupid
         left join tauthgroup_apps t3
                    on t2.siteid = t3.siteid and t2.tauthgroupid = t3.tauthgroupid
         left join system_apps t4 on t3.system_appsid = t4.system_appsid
where ((t1.fisadministrator = 1 and t2.fisused = 1 and t4.fisused=1)or t1.fissysadministrator=1)
  and t1.fusertype = 'ÆóÒµ'
  and t1.fphonenumber =$fphonenumber$