Help with Outer Join

View: New views
4 Messages — Rating Filter:   Alert me  

Help with Outer Join

by PencilEd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I have 2 docs with information that may or may not be related.  I need to get
every record, but no duplicates (if they're related - they're treated as 1).

To illustrate:
<doc1>
 <person>
  <number>123</number>
  <fname>Bob</fname>
 </person>
 <person>
  <number>345</number>
  <fname>Jane</fname>
 </person>
</doc1>

<doc2>
 <surname>
  <num>234</num>
  <lname>Smith</lname>
 </surname>
 <surname>
  <num>123</num>
  <lname>Jones</lname>
 </surname>
</doc2>

  I need to construct a Join query that will return every <num> - combining
any data where <num>'s are the same.

  Results of the query would be something like:
'123', 'Bob', 'Jones'
'234', '', 'Smith'
'345', 'Jane', ''

  I know how to get all the first names OR all the last names... don't know
how to get both.

Thanks>

  One more thing... not sure if it'll matter - but it would also be helpful
if I could Order By <num>.
--
View this message in context: http://old.nabble.com/Help-with-Outer-Join-tp26160480p26160480.html
Sent from the exist-open mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Parent Message unknown Re: Help with Outer Join

by Bivi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Do you want something like that ?

for $n in distinct-values(//(doc1|doc2)//(number|num))
        let $p := //person[number=$n]
        let $s := //surname[num=$n]
        order by $n
return
        concat("'",$n,"','",$p/fname,"','",$s/lname,"'")


     Bivi


PencilEd wrote:

>
>
> I have 2 docs with information that may or may not be related.  I need to
> get
> every record, but no duplicates (if they're related - they're treated as
> 1).
>
> To illustrate:
> <doc1>
>  <person>
>   <number>123</number>
>   <fname>Bob</fname>
>  </person>
>  <person>
>   <number>345</number>
>   <fname>Jane</fname>
>  </person>
> </doc1>
>
> <doc2>
>  <surname>
>   <num>234</num>
>   <lname>Smith</lname>
>  </surname>
>  <surname>
>   <num>123</num>
>   <lname>Jones</lname>
>  </surname>
> </doc2>
>
>   I need to construct a Join query that will return every <num> -
> combining
> any data where <num>'s are the same.
>
>   Results of the query would be something like:
> '123', 'Bob', 'Jones'
> '234', '', 'Smith'
> '345', 'Jane', ''
>
>   I know how to get all the first names OR all the last names... don't
> know
> how to get both.
>
> Thanks>
>
>   One more thing... not sure if it'll matter - but it would also be
> helpful
> if I could Order By <num>.
> --
> View this message in context:
> http://old.nabble.com/Help-with-Outer-Join-tp26160480p26160480.html
> Sent from the exist-open mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Exist-open mailing list
> Exist-open@...
> https://lists.sourceforge.net/lists/listinfo/exist-open
>
>

--
View this message in context: http://old.nabble.com/Help-with-Outer-Join-tp26182664p26195984.html
Sent from the exist-open mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: Help with Outer Join

by Bivi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
you could try this query :

for $n in distinct-values(//(person|surname)/(number|num))
        let $p:= //person[number=$n]
        let $s:= //surname[num=$n]
        order by $n
return
        concat("'",$n,"','",$p/fname,"','",$s/lname,"'")

--- Bivi

PencilEd wrote:
I have 2 docs with information that may or may not be related.  I need to get
every record, but no duplicates (if they're related - they're treated as 1).

To illustrate:
<doc1>
 <person>
  <number>123</number>
  <fname>Bob</fname>
 </person>
 <person>
  <number>345</number>
  <fname>Jane</fname>
 </person>
</doc1>

<doc2>
 <surname>
  <num>234</num>
  <lname>Smith</lname>
 </surname>
 <surname>
  <num>123</num>
  <lname>Jones</lname>
 </surname>
</doc2>

  I need to construct a Join query that will return every <num> - combining
any data where <num>'s are the same.

  Results of the query would be something like:
'123', 'Bob', 'Jones'
'234', '', 'Smith'
'345', 'Jane', ''

  I know how to get all the first names OR all the last names... don't know
how to get both.

Thanks>

  One more thing... not sure if it'll matter - but it would also be helpful
if I could Order By <num>.
--
View this message in context: http://old.nabble.com/Help-with-Outer-Join-tp26160480p26160480.html
Sent from the exist-open mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Exist-open mailing list
Exist-open@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/exist-open

Parent Message unknown Re: Help with Outer Join

by Amir Akhmedov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello, Bivi.

For function concat() input parameters must strings. In your case it
returns //person[number=$n] sequence of nodes, but not a string.

> Do you want something like that ?

> for $n in distinct-values(//(doc1|doc2)//(number|num))
>         let $p := //person[number=$n]
>         let $s := //surname[num=$n]
>         order by $n
> return
>         concat("'",$n,"','",$p/fname,"','",$s/lname,"'")


>      Bivi



--
Sincerely Yours Amir Akhmedov


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open