List:General Discussion« Previous MessageNext Message »
From:James Tu Date:April 4 2007 6:03pm
Subject:Re: Finding a record in a result set
View as plain text  
Ok, sorry.  When I described the initial scenario it wasn't exactly  
accurate.  I want to find Joe in the list of everyone hired on the  
same date as Joe.

So when I do my query,something to the effect of:
select from users where hiring_date=$target_date ORDER BY user_uniq_id;
Now the result set should be sorted by user_uniq_id.  Then I do a  
binary search using Joe's user_uniq_id.
(note user_uniq_id is an auto incremented field)

That should work, no...is there a faster/better way to do this?  Some  
people suggested creating a temporary table, but I'm just concerned  
that there may be memory impacts on the server if lots of people  
require this query.

The result set could be pretty large...1000, 10,000, maybe even  
100,000 if this app becomes popular. :)

-James


On Apr 4, 2007, at 1:21 PM, Jerry Schwartz wrote:

> That would only work if the result set is sorted by name. You said you
> wanted to sort by hiring date, that's not going to work.
>
> As for the general approach, I don't have enough experience to  
> judge. How
> big would you expect the result set to be?
>
> Regards,
>
> Jerry Schwartz
> Global Information Incorporated
> 195 Farmington Ave.
> Farmington, CT 06032
>
> 860.674.8796 / FAX: 860.674.8341
>
>
>> -----Original Message-----
>> From: James Tu [mailto:jtu@stripped]
>> 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 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, 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
>>>
>>>
>>> --
>>> MySQL General Mailing List
>>> For list archives: http://lists.mysql.com/mysql
>>> To unsubscribe:    http://lists.mysql.com/mysql?
>>> unsub=jtu@stripped
>>>
>>>
>>
>>
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe:
>> http://lists.mysql.com/mysql?unsub=1
>>
>>
>
>
>
>


Thread
Finding a record in a result setJames Tu22 Mar
  • Re: Finding a record in a result setPeter Brawley22 Mar
    • Re: Finding a record in a result setRolando Edwards22 Mar
    • RE: Finding a record in a result setJerry Schwartz22 Mar
      • Re: Finding a record in a result setFrancesco Riosa23 Mar
      • SPAM ?Jacques Brignon24 Mar
        • Re: SPAM ?LP24 Mar
        • Re: SPAM ?Martijn Tonies24 Mar
        • Re: SPAM ?Stephen Cook25 Mar
          • RE : SPAM ?Jacques Brignon25 Mar
            • RE : RE : SPAM ? SOLVEDJacques Brignon25 Mar
        • Re: SPAM ?Banyan He25 Mar
          • RE : SPAM ?Jacques Brignon25 Mar
            • Re: SPAM ?Banyan He25 Mar
  • Re: Finding a record in a result setRolando Edwards22 Mar
  • Re: Finding a record in a result setMaciej Dobrzanski24 Mar
    • Re: Finding a record in a result setJames Tu26 Mar
  • Re: Finding a record in a result setJames Tu26 Mar
  • Re: Finding a record in a result setJames Tu4 Apr
    • RE: Finding a record in a result setJerry Schwartz4 Apr
      • Re: Finding a record in a result setDan Buettner4 Apr
        • Re: Finding a record in a result setJames Tu4 Apr
          • Re: Finding a record in a result setDan Buettner4 Apr
      • Re: Finding a record in a result setJames Tu4 Apr