Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8484479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:23:30+00:00 2026-06-10T20:23:30+00:00

I have a situation where i have to identify 5 or more consecutive records

  • 0

I have a situation where i have to identify 5 or more consecutive records in the first 10 records. I have given 2 examples below:

Example 1 as follows

SL  User       Number   Frequency
1   aaa         9.95    1
2   aaa         9.85    1
3   aaa         9.75    1
4   aaa         9.65    1
5   aaa         9.55    1
6   aaa         9.45    1
7   xxxx        9.35    1
8   bbbb        9.25    1
9   cccc        9.15    1

I want a query that can pick up records 5 & 6 (Numbers 9.55 and 9.45 that belong to user aaa and update the frequency as 2 instead of 1).

Example 2 as follows

SL  User    Number  Frequency
1   xxxx     9.95   1
2   aaa      9.85   1
3   aaa      9.75   1
4   aaa      9.65   1
5   aaa      9.55   1
6   aaa      9.45   1
7   xxxx     9.35   1
8   bbbb     9.25   1
9   cccc     9.15   1

The query should pick up only record 6 (Number 9.45 that belong to user aaa and update frequency to 2 instead of 1).

The query should pick up records where 5 or more consecutive records appear anywhere in top 9 positions of a user and mark the frequency as 2 for positions after the 4th position.

Constraints:
This query is executed every 2 seconds via an ajax in a php. So i really don’t want a complex join / union query that uses lot of cpu.
I have the option of doing this in php, by breaking up into 2 or more smaller queries, but prefer a single query that does not load the cpu or database.
If a single query is likely to load the cpu i’m ok with 2-3 queries as processing happens in php.

Can you please advise how to this can be achieved ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:23:32+00:00Added an answer on June 10, 2026 at 8:23 pm

    if it is only the first 10 records, PHP solution should not be THAT consuming..

    $arr= mysql result arrays;
    $old_user="";
    $count=0;
    foreach ($arr as $a){
        if ($a['name']==$old_user){
           $count++;
        }else{
           $count=0;
        }
        if ($count > 4) {
            // run the update query here
    
        }
        $old_user=$a['name'];
    }
    

    See if it works for your need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have situation where a user can manipulate a large set of data (presented
I have situation like this: user submits form with action='/pay' in '/pay' I have
My situation is as follows. I'm using entity framework (4.0) in which I have
I have a situation where I need to identify if a list element (li)
i have situation like this: class IData { virtual void get() = 0; virtual
I have situation, where running a query that filters by an indexed column in
I have situation in which I read a record from a database. And if
I have situation where I need to change the order of the columns/adding new
We have situation where say we have four engineers that are working on software
Pseudo-situation: have a class (let's say BackgroundMagic ), and it has Start() and Stop()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.