select t1.fusertype,
       t1.fphonenumber,
       t1.fname,
       t1.fisadministrator,
       t1.frole,
       t1.fsex,
       t1.fdatamodify,
       t2.fprovince,
       t2.fcity,
       t2.fcounty,
       t2.fagentname,
       t1.tenterprise_userid,
       t2.fsaleruserid,
       t3.fname as fsaler,
       t1.faccountno,
       t1.fcanreadagentanalysis,
       t2.ftype as fagenttype
from tenterprise_users t1
       left join tagents t2 on t1.siteid = t2.siteid and t1.tagentsid = t2.tagentsid
       left join tenterprise_users t3 on t2.siteid=t3.siteid and t2.fsaleruserid=t3.tenterprise_userid
       left join countryareaid t4 on t2.fprovince=t4.id
       left join countryareaid t5 on t2.fcity=t5.id
       left join countryareaid t6 on t2.fcounty=t6.id
where (t1.fphonenumber is not null or t1.fname is not null)
  and t1.siteid =$siteid$ and $where$ and t1.fissysadministrator=0