Loading TOC...

MarkLogic 12 EA 1 Product Documentation
op:join-cross-product

op:join-cross-product(
   $leftPlan as map:map,
   $rightPlan as map:map,
   [$condition as map:map?]
) as map:map

Summary

This method yields one output row set that concatenates every left row with every right row. Matches other than equality matches (for instance, greater-than comparisons between keys) can be implemented with a condition on the cross product.

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.
$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-cross-product($expenses )
   => op:where(op:eq(op:view-col("employees", "EmployeeID"),
                     op:view-col("expenses", "EmployeeID")))
   => 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.