Tamino XQuery Outer Joins

I am familiar typical with XQuery joins in Tamino like:

for $x in input()\employee,
    $y in input()\doc

where $x/@employee_id = $y/@employee_id
</pre><BR><BR>But how would you do something like this SQL equivalent of an outer join:<BR><pre class="ip-ubbcode-code-pre">
select * from employee e
left outer join doc d on e.employeeid = d.employeeid

Just for clarity it is my understanding that the XQuery sample I provided is a inner join (no nulls on either side of the join).

Hi Larry,

you do this by nesting fLWR into the return clause, e.g.
for $x in input()/employee
return

{$x}
{for $y in input()/doc
where $x/@employee_id = $y/@employee_id
return $y}

It depends rather on the output that you want to produce. Typically, I would expect to see something like this:

for $e in input()//employee
return

{ $e/*,
let $d = input()//dept[@dept-nr = $e/dept-nr]
return if (empty($d)) then () else {$d}
}


The SQL outer join produces a table in which unavailable data is replaced by null values. Typically with XML the equivalent will be to produce elements with a variable number of child elements.

Michael Kay

Thanks Gentlemen!
Both of your responses were helpfull in my efforts!