Loading TOC...


   $leftPlan as map:map,
   $rightPlan as map:map,
   [$keys as map:map*],
   [$condition as map:map?]
) as map:map


This method returns all rows from multiple tables where the join condition is met. In the output row set, each row concatenates one left row and one right row for each match between the keys in the left and right row sets.

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.

$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.


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")
return $employees
   => op:join-inner($expenses, op:on(
          op:view-col("employees", "EmployeeID"),
          op:view-col("expenses",   "EmployeeID"))) 
   => op:select((op:view-col("employees", "EmployeeID"), 
                 "FirstName", "LastName", "Category",
                 op:view-col("expenses",   "Amount")))
   => op:order-by(op:view-col("employees", "EmployeeID"))
   => op:result() 

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.