Re: [OT] SQL-question

[prev] [thread] [next] [Date index for 2005/03/15]

From: Dave Cross
Subject: Re: [OT] SQL-question
Date: 16:52 on 15 Mar 2005
On Tue, Mar 15, 2005 at 05:23:09PM +0100, Andreas Fromm wrote:
> .--- .- -- . ... wrote:
> | There's something I must be missing in your question because as its
> | stated it seems pretty straight forward....
> |
> | select of as partner_id from relationships where is = ?
> |
> Thats one part, but what if I am asking for the partner of someone who
> itself is registred as the 'of'-person. If the recor in Relationships is
> 
> 1 is partner of 2
> 
> and then i need to find the partner of 2, I would need:
> SELECT is AS partner_id FROM Relationships WHERE of = ?
> 
> My problem is how to write both querys as one.

Do you mean:

  select of as partner_id from relationships where is = ?
  union
  select is as partner_id from relationships where of = ?

If you want to know whether the partner you have found is an of or an is
then you could use something like:

  select of as partner_id, 'of' as type from relationships where is = ?
  union
  select is as partner_id, 'is' as type from relationships where of = ?

Dave...

        -- 
          Let me see you make decisions / Without your television

[OT] SQL-question
Andreas Fromm 13:49 on 15 Mar 2005

Re: [OT] SQL-question
Andreas Fromm 16:23 on 15 Mar 2005

Re: [OT] SQL-question
Dave Cross 16:52 on 15 Mar 2005

Re: [OT] SQL-question
Kingsley Kerce 16:55 on 15 Mar 2005

Re: [OT] SQL-question
.--- .- -- . ... 16:58 on 15 Mar 2005

Generated at 21:05 on 16 Mar 2005 by mariachi v0.52