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

  • Home
  • SEARCH
  • 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 7592393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:53:40+00:00 2026-05-30T20:53:40+00:00

This is the MYSQL table schema : +—————+———————+ | username | last_activity_time | +—————+———————+

  • 0

This is the MYSQL table schema :

+---------------+---------------------+
| username      | last_activity_time  |
+---------------+---------------------+
| raphael       | 2011-11-28 23:16:34 |
| donatello     | 2011-11-28 23:17:36 |
| michaelengelo | 2011-11-29 10:08:28 |
| raphael       | 2011-11-29 11:11:33 |
| leonardo      | 2011-11-29 11:12:30 |
+---------------+---------------------+

A NEW record with username and last_activity_time is inserted for each activity.

Query requirement :

Select all users who did some activity DAILY between two dates say 2011-11-20 and 2011-11-30 ( both included )

“IN” query does not seem to be an option as it works for any value in the IN array, not ALL.

  • 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-30T20:53:41+00:00Added an answer on May 30, 2026 at 8:53 pm
    SELECT username, COUNT(*) AS nbr_day
    FROM (
        SELECT username, DATE(last_activity_time) AS last_activity_date
        FROM my_table
        WHERE ( last_activity_time >= @date1 )
        AND ( last_activity_time < DATE_ADD( @date2, INTERVAL 1 DAY) )
        GROUP BY username, last_activity_date
    ) AS sub
    GROUP BY username
    HAVING ( COUNT(*) = 1 + DATEDIFF(@date2, @date1) )
    

    This query counts the number of different days for each username. And then retain only those for which this number is equal to the number of days between the two dates.

    The expression “DATE_ADD( @date2, INTERVAL 1 DAY)” represents the date just after @date2. It it used rather than @date2 because “last_activity_time” contains date and also time.

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

Sidebar

Related Questions

Given a table named person (in a MySQL database/schema), kind of like this one:
The basic table schema looks something like this (I'm using MySQL BTW): integer unsigned
this is an example: table mysql schema : id name salary 1 david 20
In this MySQL table definition: CREATE TABLE groups ( ug_main_grp_id smallint NOT NULL default
I have this mysql table called comments which looks like this: commentID parentID type
This is the MySQL table structure that I have: itemID (BIGINT) userID (BIGINT) wasAdded
I have this in a MySQL db: table Message sender_id int recipient_id int created
I have a MySQL table like this: Payments +----+---------------------+---------+ | id | date (sorted
Let's say I have a MySQL table that is something like this: software table:
I have a table in mysql like this Name Result T1_09_03_2010 fail T2_09_03_2010 pass

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.