Try adding a self join on the Resource
table joining the ResourceId
to the CrFor
:
select t1.*,t2.pcrname,t3.ResourceName AS crforName from
Resource t1 left join Pcr t2 on t1.Pcrid=t2.pcrid left join Resource t3 on t1.CrFor = t3.ResourceId
where t1.contractid=1