Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id BFD8FAF82E9 for ; Mon, 9 Jan 2012 12:12:35 -0400 (AST) Received: from mail.prospectiv.com ([155.212.59.212] helo=stan.prospectivdirect.com) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1RkHpn-0000Hi-Pe for pgsql-sql@postgresql.org; Mon, 09 Jan 2012 16:12:35 +0000 Received: (qmail 21120 invoked from network); 9 Jan 2012 16:12:18 -0000 Received: from unknown (HELO ?192.168.1.15?) (192.168.1.15) by 0 with SMTP; 9 Jan 2012 16:12:18 -0000 Subject: compare table names From: Tony Capobianco To: pgsql-sql@postgresql.org Content-Type: text/plain; charset="UTF-8" Date: Mon, 09 Jan 2012 11:12:18 -0500 Message-ID: <1326125538.1983.12.camel@tony1.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 (2.32.3-1.fc14) Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.0 (/) X-Archive-Number: 201201/28 X-Sequence-Number: 36199 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 -------------------- tmp_staging1229 However, I'm receiving: tablename -------------------- tmp_staging0109 tmp_staging1229 tmp_staging0108 How can I write this correctly? Thanks. Tony