Re: [SQL] Alternative to INTERSECT

2007-08-01 Thread Luiz K. Matsumura
I don't know if this is more efficient but an alternative can be something like this SELECT t.id FROM test t JOIN test t2 ON t2.id = t.id AND t2.field = 'firstname' AND t2.value LIKE 'jose%' JOIN test t3 ON t3.id = t2.id AND t3.field = 'lastname' AND t3.value LIKE 'kro%' WHERE t.field = '

Re: [SQL] Alternative to INTERSECT

2007-07-31 Thread Stephan Szabo
On Tue, 31 Jul 2007, Andreas Joseph Krogh wrote: > Hi all. I have the following schema: > > CREATE TABLE test ( > id integer NOT NULL, > field character varying NOT NULL, > value character varying NOT NULL > ); > > ALTER TABLE ONLY test > ADD CONSTRAINT test_id_key UNIQUE (id, fiel

Re: [SQL] Alternative to INTERSECT

2007-07-31 Thread Rodrigo De León
On 7/31/07, Andreas Joseph Krogh <[EMAIL PROTECTED]> 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.FI

Re: [SQL] Alternative to INTERSECT

2007-07-31 Thread Andreas Joseph Krogh
On Tuesday 31 July 2007 18:52:22 Josh Trutwin wrote: > On Tue, 31 Jul 2007 17:30:51 + > > Andreas Joseph Krogh <[EMAIL PROTECTED]> wrote: > > Hi all. I have the following schema: > > > > CREATE TABLE test ( > > id integer NOT NULL, > > field character varying NOT NULL, > > value cha

Re: [SQL] Alternative to INTERSECT

2007-07-31 Thread Josh Trutwin
On Tue, 31 Jul 2007 17:30:51 + Andreas Joseph Krogh <[EMAIL PROTECTED]> wrote: > Hi all. I have the following schema: > > CREATE TABLE test ( > id integer NOT NULL, > field character varying NOT NULL, > value character varying NOT NULL > ); > > ALTER TABLE ONLY test > ADD CON

[SQL] Alternative to INTERSECT

2007-07-31 Thread Andreas Joseph Krogh
Hi all. I have the following schema: CREATE TABLE test ( id integer NOT NULL, field character varying NOT NULL, value character varying NOT NULL ); ALTER TABLE ONLY test ADD CONSTRAINT test_id_key UNIQUE (id, field, value); CREATE INDEX test_like_idx ON test USING btree (id, fiel