MarkLogic 9 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()  
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy