select t1.tagentsid,t1.tcustomerid,t2.fagentnum,t2.fagentname,t3.fstorenum,t3.fstorename,t1.fname,t1.fphonenumber,t1.fcommunity,t1.fnumber,
t1.fwechatno,t1.fbirthdate,t1.frenovationplandate  from tcustomer t1
inner join tagents t2 on t1.siteid=t2.siteid and t1.tagentsid=t2.tagentsid
left join tstore t3 on t1.siteid=t3.siteid and t1.tagentsid=t3.tagentsid and t1.tstoreid=t3.tstoreid
where t1.siteid=$siteid$ and $where$