|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Article posted on Experts Exchange about XQuery outer joinsAndrew Webster andrew at webster.orgMon Jun 21 13:43:51 PDT 2010
Hi David,
That's good, it produces exactly the output I'm after. So the process is
"for each node in tblMain, if there's a matching node (stored in $subs)
we'll return that, otherwise we'll return a placeholder".
That works.
Now the test is that I've got to write a much more complex version of this
for a many-million-row database ingested into xDB. It'll be really
interesting to try both approaches and see which will have better
performance. I'll ping the list with my findings.
Thanks,
Andrew
On Mon, Jun 21, 2010 at 11:57 AM, David Carlisle <http://x-query.com/mailman/listinfo/talk> wrote:
> On 21/06/2010 17:29, Andrew Webster wrote:
>
>> Hi all,
>>
>> I'm after some feedback on an article I've posted at How to write an
>> XQuery that is the exact equivalent of a SQL OUTER JOIN
>> <http://www.experts-exchange.com/A_3295.html>
>>
>> I don't think you need build the matched an unmatched cases separately
> and then sort them back. Also sorting on $sorted/ID will be a string sort
> and so (on saxon at least) 10 comes before 2 (I think it depends on your
> systems default collation
>
> I'd just do something like
>
> xquery version "1.0";
> <results>
> {
> for $main in doc("tblMain.xml")/dataroot/tblMain
> let $subs := doc("tblSub.xml")/dataroot/tblSub[MainID = $main/MainID]
> return
> if (exists($subs))
> then
> for $sub in $subs
> return
> <row>
> <ID>{data($main/MainID)}</ID>
> <Main>{data($main/MainText)}</Main>
> <Sub>{data($sub/Sub)}</Sub>
> </row>
> else
> <row>
> <ID>{data($main/MainID)}</ID>
> <Main>{data($main/MainText)}</Main>
> <Sub>-</Sub>
> </row>
> }
> </results>
>
>
> David
>
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20100621/a21f0ee6/attachment.htm
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






