X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 30709D1B741 for ; Wed, 28 Jul 2004 00:34:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09048-06 for ; Wed, 28 Jul 2004 03:33:57 +0000 (GMT) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id 85AD2D1D1C7 for ; Wed, 28 Jul 2004 00:23:12 -0300 (ADT) Received: from mail.logi-track.com (burro.logi-track.com [213.239.193.212]) by www.postgresql.com (Postfix) with ESMTP id 770F0CF6491 for ; Tue, 27 Jul 2004 11:21:43 -0300 (ADT) Received: from kingfisher.intern.logi-track.com (G6110.g.pppool.de [80.185.97.16]) by mail.logi-track.com (Postfix) with ESMTP id 288A730197; Tue, 27 Jul 2004 14:27:35 +0000 (UTC) Received: from kingfisher.intern.logi-track.com (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with SMTP id 32A37AB2D0; Tue, 27 Jul 2004 16:21:18 +0200 (CEST) Date: Tue, 27 Jul 2004 16:21:17 +0200 From: Markus Schaber To: "Merlin Moncure" Cc: Subject: Correction of best way to fetch next/prev record based on index Message-Id: <20040727162117.6de666b6@kingfisher.intern.logi-track.com> In-Reply-To: <20040727161325.213b11eb@kingfisher.intern.logi-track.com> References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> <20040727161325.213b11eb@kingfisher.intern.logi-track.com> Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K You mut not Should be "must", not "mut" :-) > > My problem is deceptively simple: how you read the next record from > > a table based on a given set of values? In practice, this is > > difficult to implement. If anybody can suggest a alternative/better > > way to this, I'm all ears. >=20 > So you really want something like >=20 > 'SELECT * FROM t WHERE a>=3Da1 AND b>=3Db1 AND c>=3Dc1 ORDER BY a,b,c ASC > LIMIT 1' Sorry, as you want the _next_, and I assume that a1, b1 and c1 are the current row's values, you should rather use something like: 'SELECT * FROM t WHERE a>=3Da1 AND b>=3Db1 AND c>=3Dc1 ORDER BY a,b,c ASC LIMIT 1 OFFSET 1' HTH, Markus --=20 markus schaber | dipl. informatiker logi-track ag | rennweg 14-16 | ch 8001 z=FCrich phone +41-43-888 62 52 | fax +41-43-888 62 53 mailto:schabios@logi-track.com | www.logi-track.com