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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:16:07+00:00 2026-05-17T19:16:07+00:00

I am using this query: SELECT p.id, count(clicks.ip) FROM `p` LEFT JOIN c clicks

  • 0

I am using this query:

SELECT p.id, count(clicks.ip)
FROM `p`
LEFT JOIN c clicks ON p.id = clicks.pid
WHERE clicks.ip = '111.222.333.444'

To select clicks from table “c”, that has “pid” = “p.id”. The query seems to work fine, but now I want to use that query with date ranges. The “c” table has a column “time” that uses MySQL CURRENT_TIMESTAMP data type (YYYY-MM-DD HH:MM:SS). How can I use my query with date range using that column?

I want to be able to select count(clicks.ip) from a specific day, and also group the results by hour (but this is for a different query).

  • 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-17T19:16:07+00:00Added an answer on May 17, 2026 at 7:16 pm

    Use:

       SELECT p.id, 
              COUNT(clicks.ip)
         FROM `p`
    LEFT JOIN c clicks ON clicks.pid = p.id 
                      AND clicks.ip = '111.222.333.444'
                      AND clicks.time BETWEEN DATE_SUB(NOW(), INTERVAL 1 DAY)
                                          AND NOW()
    

    I provided an example that will count clicks that occurred between this time yesterday (DATE_SUB(NOW(), INTERVAL 1 DAY)) and today (NOW()). Mind that BETWEEN is inclusive.

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

Sidebar

Related Questions

I am using this query: SELECT DISTINCT pat.PublicationID FROM dbo.PubAdvTransData AS pat INNER JOIN
so suppose I have this query SELECT COUNT(*) FROM (SELECT * FROM k JOIN
I'm using this query to list duplicate records SELECT DISTINCT column1 from table group
I have this query: SELECT COUNT(*) AS `numrows` FROM (`tbl_A`) JOIN `tbl_B` ON `tbl_A`.`B_id`
I am using this query SELECT COUNT(DISTINCT to_number) AS errors FROM sent_txts WHERE msg_link_id
When using this SQL query: Select * from table_name what happens if the name
i've been using the following query: select LEN(columnname) as columnmame from dbo.amu_datastaging This works,
I count MySQL rows using this function: function sqlcount($table) { $sql = mysql_query(SELECT COUNT(0)
I'm running a query that looks like this: $results = $DB2->query(SELECT COUNT(*) FROM auth_user
I am using this query: SELECT district, id FROM adverts ls GROUP BY district,

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.