Filter tables

From: Reg Me Please <regmeplease(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Filter tables
Date: 2007-11-12 15:43:51
Message-ID: 200711121643.51645.regmeplease@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all.

I have this sample setup:

CREATE table t1 ( t text, id int );
CREATE TABLE f1 ( t text );

INSERT INTO t1 VALUES
( 'field1',1 ),
( 'field2',1 ),
( 'field3',1 ),
( 'field1',2 ),
( 'field3',3 )
;

INSERT INTO f1 VALUES
( 'field1' ),
( 'field2' )
;

What I'd need to do is to "filter" t1 against f1 to get only the rows
( 'field1',1 ) and ( 'field2',1 ).
Of course both t1 and f1 don't have a defined number of rows, though usually
t1 should be much bigger that f1.

I have a rather complex solution in mind with loops in a plpgsql function and
am wondering whether there is one simpler.

Thanks a lot.

--
Reg me Please

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gauthier, Dave 2007-11-12 15:54:53 reverse strpos?
Previous Message Scott Marlowe 2007-11-12 15:41:45 Re: Linux v.s. Mac OS-X Performance