[OT] SQL-question

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

From: Andreas Fromm
Subject: [OT] SQL-question
Date: 13:49 on 15 Mar 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

i know I'm slightly off topic, but I don't know where else to ask. I
have a little SQL-question abaut a linking table. I have the following
tables:

CREATE TABLE Person (
~  id serial PRIMARY KEY
~  name text,
~  ...
);

CREATE TABLE Relations (
~  is integer REFERENCES Person,
~  rel char(7) CHECK ( rel == 'partner' OR ... ),
~  of integer REFERENCES Person,
~  CONSTRAINT Relations_pkey PRIMARY KEY ( is, rel )
);

Now I would like to make a query to the Relations table asking if some
'person' is the partner of another, and get the id of the partner. How
would the SQL look like if I just have the row (1 is partner of 2) and
not the row (2 is partner of 1) in the Relations table?

Thanks in advance.

- --
Grüße,

Andreas Fromm

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCNufdUmBtSMq5cGURAhgaAKCgyYcy4rhZlw2aXJSZw6zdXr1mfgCg3Bjx
B/4DhJaybQIZmreKps5VbHs=
=srgW
-----END PGP SIGNATURE-----

[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