[SQL] compare table names

2012-01-09 Thread Tony Capobianco
I have these 3 tables: tablename tmp_staging0109 tmp_staging1229 tmp_staging0108 I'd like this query: select tablename from pg_tables where tablename like 'tmp_staging%' and tablename 'tmp_staging1230'; To return this result: tablename

Re: [SQL] compare table names

2012-01-09 Thread Adrian Klaver
On Monday, January 09, 2012 8:12:18 am Tony Capobianco wrote: I have these 3 tables: tablename tmp_staging0109 tmp_staging1229 tmp_staging0108 I'd like this query: select tablename from pg_tables where tablename like 'tmp_staging%' and tablename

Re: [SQL] compare table names

2012-01-09 Thread Tony Capobianco
I see what you're saying: pg=# select tablename from pg_tables where tablename like 'tmp_staging%' and tablename 'tmp_staging1230' and tablename 'tmp_staging1228'; tablename tmp_staging1229 This query is part of a larger script where I want to dynamically

Re: [SQL] compare table names

2012-01-09 Thread Adrian Klaver
On Monday, January 09, 2012 8:12:18 am Tony Capobianco wrote: tablename tmp_staging0109 tmp_staging1229 tmp_staging0108 How can I write this correctly? Had another idea. If you are looking for the highest numbered table below a certain number then maybe

Re: [SQL] compare table names

2012-01-09 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 tmp_staging1229 This query is part of a larger script where I want to dynamically select tablenames older than 10 days and drop them. The tables are created in a tmp_stagingMMDD format. I know postgres does not maintain object create

Re: [SQL] compare table names

2012-01-09 Thread Adrian Klaver
On Monday, January 09, 2012 8:28:43 am Tony Capobianco wrote: I see what you're saying: pg=# select tablename from pg_tables where tablename like 'tmp_staging%' and tablename 'tmp_staging1230' and tablename 'tmp_staging1228'; tablename tmp_staging1229 This