Re: [OT] SQL-question
[prev]
[thread]
[next]
[Date index for 2005/03/15]
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