2

In the following XQuery syntax, I've added in the last table with a CROSS APPLY, and it seems to filter out some records. It would seem that this is the case because the node defined is optional. I thought that my code would result in the equivalent of a LEFT OUTER JOIN, however it is behaving like an INNER.

FROM   
      xxx_XML CROSS APPLY 
      XmlData.nodes('/reports/report/xxx-report') AS xxx(pref) CROSS APPLY
      pref.nodes('summary') AS Summary(sref) CROSS APPLY
      pref.nodes('data/proj-title/title-code') AS Title(tref) 

Is there a better way to handle this?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Chris
  • 21
  • 2

1 Answers1

2

I thought that my code would result in the equivalent of a LEFT OUTER JOIN, however it is behaving like an INNER.

If you want apply to behave like an outer join you could use outer apply.

Mikael Eriksson
  • 136,425
  • 22
  • 210
  • 281