Thanks Maciek:
The table that I'm doing this query on will be huge. It's
essentially the users table for an online activity with, we hope,
lots of users. :)
The thing is that if I do a query for the entire result set and use
PHP to figure out the position of the user and then do a query on a
page of results that will contain the user, I'm still going to take a
hit right?
Or are you concerned about performance b/c MySQL and subqueries are
really slow?
-James
On Mar 23, 2007, at 8:05 PM, Maciej Dobrzanski wrote:
"James Tu" <[EMAIL PROTECTED]> wrote in message =
news:[EMAIL PROTECTED]
I want to do a query of all employees from Maine, ordered by
hiring =20
date, and figure out where Joe falls in that list. (i.e. which
record =
number is he?)
I think this can only be accomplished with a temporary table.
SET @n:=3D0;
SELECT t.name, t.n FROM (SELECT @n:[EMAIL PROTECTED] AS n, name FROM t WHERE
state =
=3D 'Maine' ORDER BY hire DESC) t WHERE t.name =3D 'Foo';
This query though may not be suitable for most situations as its =
performance depends heavly on the size of the derived table.=20
Maciek
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?
[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]