MarkLogic 12 EA 1 Product Documentation
op:join-left-outer

op:join-left-outer(
   $leftPlan as map:map,
   $rightPlan as map:map,
   [$keys as map:map*],
   [$condition as map:map?]
) as map:map

Summary

This method yields one output row set with the rows from an inner join as well as the other rows from the left row set.

The join performs natural joins between columns with the same identifiers. To prevent inadvertent natural joins, specify a different qualifier for the left or right columns or use different column names for the left and right columns.

Parameters
$leftPlan The row set from the left view.
$rightPlan The row set from the right view.
$keys The equijoin from one or more calls to the op:on function.
$condition A boolean expression that filters the join output rows.

Example

xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";

let $employees := op:from-view("main", "employees")
let $expenses  := op:from-view("main", "expenses")
let $totalexpenses  := op:col("totalexpenses")
return $employees
   => op:join-left-outer($expenses, op:on(
                  op:view-col("employees", "EmployeeID"),
                  op:view-col("expenses", "EmployeeID")))
   => op:group-by(op:view-col("employees", "EmployeeID"),
                 ("FirstName", "LastName",
                  op:view-col("expenses", "Category"),
                  op:sum($totalexpenses,
                  op:view-col("expenses", "Amount"))))
   => op:order-by(op:view-col("employees", "EmployeeID"))

   => op:result()
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy