--------------------------------- example:
begin;
create table u (uid int, aid int, txt text); create table a (id int, pkey int); create table p (uid int, pkey int, val text);
insert into u VALUES(1,1,'one'); insert into u VALUES(2,1,'two'); insert into u VALUES(3,1,'three');
insert into a VALUES(1, 9);
insert into p VALUES(1,9,'ONE'); insert into p VALUES(3,9,'THREE');
-- doesn't get 2, because there is no entry in p for it
SELECT u.uid, u.txt, p.val FROM u,a,p WHERE u.uid = p.uid and a.id = u.aid and p.pkey = a.pkey;
-- works, but uses a subselect
SELECT u.uid, u.txt, (SELECT p.val FROM p WHERE p.uid = u.uid AND p.pkey = a.pkey) FROM u,a WHERE a.id = u.aid;
--doesn't work: ERROR: JOIN/ON clause refers to "u", which is not part of JOIN
SELECT u.uid, u.txt, p.val FROM u,a LEFT JOIN p ON p.uid = u.uid AND p.pkey = a.pkey WHERE a.id = u.aid;
abort;
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly