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 6791881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:54:01+00:00 2026-05-26T17:54:01+00:00

Not sure how best to word this, so please bear with me. My table

  • 0

Not sure how best to word this, so please bear with me. My table (simplified) is as follows:

  • id – Integer – auto increment
  • user_id – Integer
  • timestamp – Datetime

What I need is the ability to query this table and select all records where the timestamp columns are within a predefined time range (potentially arbitrary, but lets say 10 minutes) for each user_id.So, for example, I would like to know if there is an entry for hypothetical user_id 5 at “2011-01-29 03:00:00” and then next at “2011-01-29 03:02:00” but not if a user searched once at “2011-01-29 03:00:00” and then next at “2011-01-29 05:00:00”. This would also need to capture instances where a user searches more than 2 times, each within the time range of the previous.

For background, this is a table of site searches, and I would like to know all instances where a user searches for something, then searches again (presumably because their previous search did not provide the results they were looking for).

I know this is probably simpler than I am making it out to be, but I can’t seem to figure it out. I can clarify or provide additional info if needed. Thanks!

EDIT:
I am interested in the search returning results for all of the users in the table, not just user #5, and also to search without input of the actual times. The timestamp should not be something which is manually input, but should instead should find rows by each user which are within 10 minutes of one another.

  • 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-05-26T17:54:01+00:00Added an answer on May 26, 2026 at 5:54 pm
    SELECT distinct t1.user_id, t1.another_field, t1.another_field
    FROM
        table t1,
        table t2
    WHERE
    t1.user_id = t2.user_id
    AND abs(timestampdiff(MINUTE, t1.timestamp, t2.timestamp)) < 10
    

    if you want to further limit the results, you can add

    AND t1.user_id = any_number (or IN or between, etc)
    

    To restrict date range add,

    AND t1.timestamp BETWEEN A and B (or > or <)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure the best way to word this question so bear with me.
I'm not entirely sure if this is the best way to word it, however,
I am not too sure the best way to word this, but what I
I'm not sure how to best word this, so I'll give it a shot
I'm not sure how best to word the Title of this, so if someone
Sorry if this has been asked, I am not sure how to best word
I'm not sure how to best explain this, so this may be a bit
So I'm not sure what the best way to accomplish this is, but basically
Ok so this is alittle bit obscure and I'm not sure its the best
I am not sure the best way to go about this, basically I have

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.