Loading TOC...

MarkLogic 12 EA 2 Product Documentation
op:intersect

op:intersect(
   $leftPlan as map:map,
   $rightPlan as map:map
) as map:map

Summary

This method restricts the left row set to rows where a row with the same columns and values exists in the right row set.

Parameters
$leftPlan The row set from the left view.
$rightPlan The row set from the right view.

Example

xquery version "1.0-ml";

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

let $tab1 := op:from-literals((
   map:entry("id", 1) => map:with("val", "a"),
   map:entry("id", 2) => map:with("val", "b"),
   map:entry("id", 3) => map:with("val", "c")
   ))
let $tab2  := op:from-literals((
   map:entry("id", 1) => map:with("val", "x"),
   map:entry("id", 2) => map:with("val", "b"),
   map:entry("id", 3) => map:with("val", "c")
   ))
return $tab1
   => op:intersect($tab2)
   => op:order-by("id")
   => op:result()
  

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