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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:29:16+00:00 2026-05-14T14:29:16+00:00

I have 3 tables with a column in each which relates to one ID

  • 0

I have 3 tables with a column in each which relates to one ID per row. I am looking for an sql statement query which will check all 3 tables for any rows in the last 24 hours (86400 seconds) i have stored timestamps in each tables under column time.

After I get this query I will be able to do the next step which is to then check to see how many of the ID’s a reoccurring so I can then sort by most popular in the array and limit it to the top 5…

Any ideas welcome! 🙂

Thanks in advance.

Stefan

  • 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-14T14:29:17+00:00Added an answer on May 14, 2026 at 2:29 pm
    SELECT  id, COUNT(*) AS cnt
    FROM    (
            SELECT  id
            FROM    table1
            WHERE   time >= NOW() - INTERVAL 1 DAY
            UNION ALL
            SELECT  id
            FROM    table2
            WHERE   time >= NOW() - INTERVAL 1 DAY
            UNION ALL
            SELECT  id
            FROM    table3
            WHERE   time >= NOW() - INTERVAL 1 DAY
            ) q
    GROUP BY
            id
    ORDER BY
            cnt DESC
    LIMIT 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I want to have two tables each have an INT id column which
I have a table column where each row has one of three states, and
Does each column of a table in SQL Server have a unique id? I've
I have two tables one has a three column composite key. The other needs
I have a table with a Date column. Each Date may appear multiple times.
I have created script to find selectivity of each columns for every tables. In
I have two tables: object that has object_id column and avalues that have object_id
I have several tables whose only unique data is a uniqueidentifier (a Guid) column.
I have three tables products, sales and costs. The sales and products table each
I have a common database joining situation involving three tables. One table, A, is

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.