The most common way to do a join will be to create a cts query construct
like this:


If my documents were like this-

<document-a>
  <filename>3223235432.jpg</filename>
  <title>This is a simple example</title>
  <caption>whatever other data can be in the doc, but we will use filename
as the key</caption>
</document-a>

<document-b>
  <filename>3223235432.jpg</filename>
  <workflow-status>pending</workflow-status>
  <comment>Needs approval from Mr. Brown</comment>
</document-b>

I could join my metadata in document-a to workflow-status in document-b
with this query construct-

cts:search(/document-a,cts:element-value-query(xs:QName("filename"),cts:element-value-query(xs:QName("workflow-status"),"pending","exact")/filename,"exact"))

To make this easier to read/explain, here it is with line breaks and spaces
to show the query...

cts:search(/document-a,
    cts:element-value-query(xs:QName("filename"),

cts:element-value-query(xs:QName("workflow-status"),"pending","exact")/filename,
    "exact")
)

As you can see, I have a query construct with an XPath *
cts:element-value-query(xs:QName("workflow-status"),"pending","exact")/filename
* inside another query as the search term for it.






On Thu, Apr 4, 2013 at 7:32 AM, Sudhir Bisht <[email protected]>wrote:

> Hi All,
>
> This is my first mail in the group and am new to MarkLogic as well.
>
> I want to run an xquery code which joins two relational tables.
> Both these tables have got a column of XMLType data but they are joined on
> the basis of a non relational column i.e. using PK-FK relation.
> So using Xquery alone I can save the XMLType data as an XMLFile and then
> query it.
> But how do I work on this PK-FK thing now.
>
> - Do I need to add these in XML files only.
> Or
> - Use something like suggested in - "SQL Data Modelling Guide of MarkLogic
> " through ODBC server.
>
> Thanks..
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to