James, one option would be to run a query to find the number of people in
the list ahead of him, rather than determining position within the result
SELECT COUNT(*) FROM some_table
WHERE state = "Maine"
AND hire_date < (SELECT hire_date FROM some_table
WHERE last_name = "Smith"
AND first_name = "Joe"
AND state = "Maine")
> On Mar 22, 2007, at 11:21 AM, James Tu wrote:
> > > Is there some quick way to do the following in MySQL? (I know I
> > > can use PHP to search through the result set, but I wanted to see
> > > if there's a quick way using some sort of query)
> > >
> > > Let's say I know that Joe is from Maine.
> > > I want to do a query of all employees from Maine, ordered
> > by hiring
> > > date, and figure out where Joe falls in that list. (i.e. which
> > > record number is he?)
> > >
> > > -James