Re: Finding a record in a result set

2007-04-04 Thread Dan Buettner
Then you just have to come up with some other criteria for determining who should be counted as "before" or "after" Joe, which might well be the same as the order by clause in whatever you're doing right now while examining the result set. I think your approach of examining the result set will wo

Re: Finding a record in a result set

2007-04-04 Thread James Tu
That is a nice idea, I'll have to keep it in my bag of tricks. However, I don't know if it will work b/c there are probably others that are hired on the same date... On Apr 4, 2007, at 1:51 PM, Dan Buettner wrote: James, one option would be to run a query to find the number of people in th

Re: Finding a record in a result set

2007-04-04 Thread James Tu
Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: James Tu [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 04, 2007 1:05 PM To: James Tu Cc: MySQL List Subject: Re: Finding a record in a result set Right now I'm trying to use PHP to do a binary search on the

Re: Finding a record in a result set

2007-04-04 Thread Dan Buettner
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 set. As in: SELECT COUNT(*) FROM some_table WHERE state = "Maine" AND hire_date < (SELECT hire_date FROM some_table WHERE last_name = "Smith" AND fi

RE: Finding a record in a result set

2007-04-04 Thread Jerry Schwartz
nformation Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 > -Original Message- > From: James Tu [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 04, 2007 1:05 PM > To: James Tu > Cc: MySQL List > Subject: Re: Finding a record in a

Re: Finding a record in a result set

2007-04-04 Thread James Tu
Right now I'm trying to use PHP to do a binary search on the result set so I don't have to traverse the entire result set. I'm using PHP's mysql_data_seek() to move the pointer within the result set and looking at the data. What do people think of this approach? -James On Mar 22, 2007, a

Re: Finding a record in a result set

2007-03-26 Thread James Tu
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 o

Re: Finding a record in a result set

2007-03-26 Thread James Tu
Let me describe the problem another way, too. It's related to creating a paging interface to view many records. I figured that people deal with paging all the time and the solution to my problem may already be out there. Typically when you access a single record via a top down method, i.e

Re: Finding a record in a result set

2007-03-23 Thread Maciej Dobrzanski
"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 ta

Re: Finding a record in a result set

2007-03-23 Thread Francesco Riosa
omething? Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: Peter Brawley [mailto:[EMAIL PROTECTED] Sent: Thursday, March 22, 2007 12:33 PM To: James Tu Cc: MySQL List Subject:

RE: Finding a record in a result set

2007-03-22 Thread Jerry Schwartz
Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 > -Original Message- > From: Peter Brawley [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 22, 2007 12:33 PM > To: James Tu > Cc: MySQL List > Subjec

Re: Finding a record in a result set

2007-03-22 Thread Rolando Edwards
Remember ME is Maine MA is Massachusettes - Original Message - From: "Peter Brawley" <[EMAIL PROTECTED]> To: "James Tu" <[EMAIL PROTECTED]> Cc: "MySQL List" Sent: Thursday, March 22, 2007 12:32:41 PM (GMT-0500) Auto-Detected Subject: Re: Findin

Re: Finding a record in a result set

2007-03-22 Thread Rolando Edwards
This may sound a little cheesy, but hear me out. Create a temp table in memory holding the result of the your employee query like this: CREATE TEMPORARY TABLE tmpEmpFromState ( EMPNAME VARCHAR(60), HIRED DATE, ID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID), KEY OrderOfHire(HIRED,ID) ) ENGINE=M

Re: Finding a record in a result set

2007-03-22 Thread Peter Brawley
>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?) If 'Joe' is a unique name LOL... SELECT 1 + COUNT(*) FROM employees WHERE name <> 'Joe' AND state = 'MA' AND hiredate < ; PB James Tu wro