X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7EC27D1B517 for ; Fri, 7 Nov 2003 12:27:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95102-10 for ; Fri, 7 Nov 2003 08:27:21 -0400 (AST) Received: from smurfer.pastoraat (minas-2.demon.nl [212.238.194.105]) by svr1.postgresql.org (Postfix) with ESMTP id 8F295D1B502 for ; Fri, 7 Nov 2003 08:27:17 -0400 (AST) Received: from minas.demon.nl (athlon.pastoraat [192.168.1.1]) by smurfer.pastoraat (8.12.8/8.12.8) with ESMTP id hA7CRaHm002286 for ; Fri, 7 Nov 2003 13:27:37 +0100 Message-ID: <3FAB9036.6000900@minas.demon.nl> Date: Fri, 07 Nov 2003 13:29:42 +0100 From: Michiel Lange User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: I feel a bit dumb, but getting a bit clueless Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=USER_AGENT_MOZILLA_UA X-Spam-Level: X-Archive-Number: 200311/116 X-Sequence-Number: 11104 I am certainly not awake, that I have troubles with a simple thing like this, but there it is.... I have three tables: Names(NameID INT4 PRIM INDEX, Name VARCHAR(30)), Groups(GroupID INT4 PRIM INDEX, Group VARCHAR(30)) And a table Members(NameID,GroupID) PRIM INDEX ON (NameID, GroupID) Now I put some data in all three tables, first created some Names (a grand total of 4) and a few groups (a grand total of 6) And Members like this (NameID, GroupID) 1, 1 1, 2 1, 3 2, 1 2, 4 2, 5 3, 2 3, 6 4, 1 Now I want to show essentially the Members table, but the numbers should be replaced by the Names that go with the ID. When I try this query: SELECT "Name", "Group" FROM "Names", "Groups" RIGT JOIN "Members" ON 'Names.NameID' = 'Members.NameID' AND 'Groups.GroupID' = 'Members.GroupID'; I get 24 results (6 times 4 = 24) so, it shows like all names are member of all groups... That's not true... If I change from a LEFT JOIN to a RIGHT JOIN, it gets even stranger: I get 36 (4 * 9) results... but the name for Group is left empty. So somewhere I make a huge thinking mistake... but getting a bit clueless where I am going wrong... Can someone help me out? It gets frustrating... :( - feeling a bit silly too, this is basics... - Michiel