X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0B494D791E for ; Fri, 2 Sep 2005 16:40:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87003-06 for ; Fri, 2 Sep 2005 19:40:27 +0000 (GMT) Received: from hotmail.com (bay101-f22.bay101.hotmail.com [64.4.56.32]) by svr1.postgresql.org (Postfix) with ESMTP id C959CD86D4 for ; Fri, 2 Sep 2005 16:40:24 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 2 Sep 2005 12:40:25 -0700 Message-ID: Received: from 64.4.56.200 by by101fd.bay101.hotmail.msn.com with HTTP; Fri, 02 Sep 2005 19:40:24 GMT X-Originating-IP: [64.4.56.200] X-Originating-Email: [x_download@hotmail.com] X-Sender: x_download@hotmail.com From: "DownLoad X" To: pgsql-sql@postgresql.org Subject: Searching for results with an unknown amount of data Date: Fri, 02 Sep 2005 20:40:24 +0100 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-OriginalArrivalTime: 02 Sep 2005 19:40:25.0787 (UTC) FILETIME=[2A62F0B0:01C5AFF6] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.75 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, MSGID_FROM_MTA_HEADER=0] X-Spam-Level: * X-Archive-Number: 200509/44 X-Sequence-Number: 22591 Hi, I've got two tables, A and B, the first one containing columns A_ID | info where A_ID is primary, so that this table stores various information about an object, and the second containing columns A_ID | property where property is an integer referring to a particular property that an object may possess. I've seperated these into two tables so that an object may have several (ie an unknown number of) properties. Now, I want to find all objects that have at most properties 1,2,3, say (so something with (1,2) is okay, as is (1,2,3)). I can't see a way to do this -- can anyone help? Also, what if I want to find all the objects possessing properties 4,5,6, as well as possibly other things? I've done it with nested SELECTs (constructed programmatically), but I think this is quite slow and not a very pleasing solution. Obviously, both these things will need to be done for an arbitrary list of integers. Thanks, DL