select t1.tnoticeid,t1.fleavemessage,t1.fscore,t1.createby,t1.createdate,t2.fusertype,t2.frole,t3.fagentname from DSBCRM..tnotice_users t1
  inner join tenterprise_users t2 on t1.siteid=t2.siteid and t1.tenterprise_userid=t2.tenterprise_userid
  left join tagents t3 on t2.siteid=t3.siteid and t2.tagentsid=t3.tagentsid
where t1.siteid=$siteid$ and t1.tnoticeid=$tnoticeid$ and $where$ and (t3.fsaleruserid in $tenterprise_userid$ or t1.tenterprise_userid in $tenterprise_userid$)