0

What is the differences between cross apply and inner join ?

Especially in case of selecting top 1 ?

select 
    r.userId, acceptorId, pspCode, terminalId, zoneName, zoneCode     
from  
    reports..Report_950226 r        
cross apply
    (select top 1 
         acceptorId, branchCode, terminalId, pspCode
     from
         registerUser_AcceptorProfile ra
     where 
         ra.userId = r.userId 
     order by 
         id_ desc) acceptor 
inner join 
    registerUser_Branch branch on  branch.branchCode = acceptor.branchCode
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Moolerian
  • 534
  • 6
  • 18
  • Do you mean: CROSS APPLY vs _self_ JOIN in case of hierarchical (self referencing FK) table? – g.pickardou May 15 '16 at 09:28
  • See the following [answer](http://stackoverflow.com/questions/1139160/when-should-i-use-cross-apply-over-inner-join). This covers your question and much more. – Peter Smith May 15 '16 at 09:42
  • I want to join two table with many-one relation and select one of the row comes from that table with many row . Is it A right way to use Cross Apply or i should join if so , what is the advantages ? – Moolerian May 15 '16 at 09:59

0 Answers0