On Mon, Apr 23, 2007 at 09:26:53AM -0400, Stephen Oberholtzer wrote:
On 4/22/07, Gilles Roy <[EMAIL PROTECTED]> wrote:
Given a arbitrary statement, I need to find out which row a specific
result is in, as efficiently as possible. The arbitrary statement can
order the results any way it wants.

Let's say your resultset consists of 3 columns: memberid, lastname,
firstname.  Then you can do this:

create temp table _results (rownumber int AUTOINCREMENT, memberid int,
lastname text, firstname text);

insert into _results (memberid, lastname, firstname)
select memberid, lastname, firstname
from MainTable where whatever;

select * from _results where memberid=12345;

While this isn't a whole lot more efficient than just pulling
everything into the application and doing it that way, it will work
out a bit better if you need to do this for multiple member IDs.

This is the closest to what I was looking for. Thanks to all for the suggestions.

Regards,
Gilles

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to