2
votes

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?

1

1 Answers

2
votes

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.