Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 17D2C9FBCAF for ; Tue, 31 Jul 2007 17:31:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 36246-05 for ; Tue, 31 Jul 2007 17:30:20 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.226]) by postgresql.org (Postfix) with ESMTP id 47B759FBB9E for ; Tue, 31 Jul 2007 17:30:23 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id i4so264963wra for ; Tue, 31 Jul 2007 13:30:18 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=YjeICGoxtc39p27dEx1n/f08tM4TvMIXOXM6+/Iap6hBT09BoKM4HCZ6UEuAQZp2KDdhB3EC3vnXylTc8Qsvz+TNva05E6/GGMslsTB16fT483iZ7d/W79atfwwOtmSrOAeK0HY6/pvthvxHaJGVvYEGpvIR8UFMDa2lPRiaaN0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=WmnqoiGCcfCog3nTabnbOFGpjeQJKPUoPsyuGeyvv11aRG/WzoQ7jLvaJWfzWnCTrw3wMYeMii+e+xww9k20GwmvtGqVZOs9zipmo2I+uYUU81FZ/gl3bUKCFSflP57AHSgoTmm5YhvYAeUBEEcRCZhd13A8UXXyma7Ia93bVOs= Received: by 10.100.121.12 with SMTP id t12mr5545721anc.1185913818009; Tue, 31 Jul 2007 13:30:18 -0700 (PDT) Received: by 10.100.33.20 with HTTP; Tue, 31 Jul 2007 13:30:17 -0700 (PDT) Message-ID: Date: Tue, 31 Jul 2007 15:30:17 -0500 From: "=?UTF-8?Q?Rodrigo_De_Le=C3=B3n?=" To: "Andreas Joseph Krogh" Subject: Re: Alternative to INTERSECT Cc: pgsql-sql@postgresql.org In-Reply-To: <200707311730.51280.andreak@officenet.no> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200707311730.51280.andreak@officenet.no> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/202 X-Sequence-Number: 28937 On 7/31/07, Andreas Joseph Krogh wrote: > Is there a way to make this more efficient with another construct, or > INTERSECT the only way to accomplish the desired result? SELECT f1.ID FROM TEST f1 JOIN TEST f2 ON f1.ID = f2.ID JOIN TEST f3 ON f2.ID = f3.ID WHERE f1.FIELD = 'firstname' AND f1.VALUE LIKE 'andrea%' AND f2.FIELD = 'firstname' AND f2.VALUE LIKE 'jose%' AND f3.FIELD = 'lastname' AND f3.VALUE LIKE 'kro%';