Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 0E694AF82E9 for ; Mon, 9 Jan 2012 12:20:07 -0400 (AST) Received: from mail-tul01m020-f174.google.com ([209.85.214.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RkHx7-0000Ra-5d for pgsql-sql@postgresql.org; Mon, 09 Jan 2012 16:20:06 +0000 Received: by obcwo16 with SMTP id wo16so4281019obc.19 for ; Mon, 09 Jan 2012 08:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; bh=07kDzCNCF2HzLOhx+bua5UE0ZfvLVN+US1qeYUSUuqI=; b=gvg0B9LBsLb0Fgf9/rGQOmbkUq9xJ0kA1y7hAmwOglouzUNg0VZAqAhmkUeVRDb+La mFqr5/yCdSYDCwBWF3ty5UNc6bTt8cKPh2LcVBWKibjZcAAXDJ3qDkyBo3yMzbXDGxUH CyjSOqC+BCOO9oNcSHHfi3qxJ5S/ux9p88XmU= Received: by 10.182.74.66 with SMTP id r2mr15238047obv.67.1326125992147; Mon, 09 Jan 2012 08:19:52 -0800 (PST) Received: from tucker.localnet (c-24-17-164-54.hsd1.wa.comcast.net. [24.17.164.54]) by mx.google.com with ESMTPS id rv3sm4186434obb.9.2012.01.09.08.19.50 (version=SSLv3 cipher=OTHER); Mon, 09 Jan 2012 08:19:51 -0800 (PST) From: Adrian Klaver To: pgsql-sql@postgresql.org Subject: Re: compare table names Date: Mon, 9 Jan 2012 08:19:47 -0800 User-Agent: KMail/1.13.5 (Linux/2.6.32-37-generic; KDE/4.4.5; i686; ; ) Cc: Tony Capobianco References: <1326125538.1983.12.camel@tony1.localdomain> In-Reply-To: <1326125538.1983.12.camel@tony1.localdomain> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201201090819.48041.adrian.klaver@gmail.com> X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201201/29 X-Sequence-Number: 36200 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 < '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? As far as I can tell it is correct. 0108,0109 and 1229 are all less than 1230. What happens if you do?: select tablename from pg_tables where tablename like 'tmp_staging%' and tablename < 'tmp_staging1230' and tablename > 'tmp_staging1228; > > Thanks. > Tony -- Adrian Klaver adrian.klaver@gmail.com