Search Postgresql Archives

Filter tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux