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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:25:36+00:00 2026-05-18T01:25:36+00:00

I currently have two tables, one is called games, the other called rounds. Here

  • 0

I currently have two tables, one is called games, the other called rounds. Here is the structure to help out:

rounds

+-------------+----------+------+-----+---------+----------------+
| Field       | Type     | Null | Key | Default | Extra          |
+-------------+----------+------+-----+---------+----------------+
| id          | int(11)  | NO   | PRI | NULL    | auto_increment |
| schedule_id | int(11)  | NO   | MUL | NULL    |                |
| open_date   | datetime | NO   |     | NULL    |                |
| close_date  | datetime | NO   |     | NULL    |                |
| start_date  | datetime | NO   |     | NULL    |                |
| end_date    | datetime | NO   |     | NULL    |                |
+-------------+----------+------+-----+---------+----------------+

games

+-------------+----------+------+-----+---------+----------------+
| Field       | Type     | Null | Key | Default | Extra          |
+-------------+----------+------+-----+---------+----------------+
| id          | int(11)  | NO   | PRI | NULL    | auto_increment |
| schedule_id | int(11)  | NO   | MUL | NULL    |                |
| team_a      | int(11)  | NO   | MUL | NULL    |                |
| team_b      | int(11)  | NO   | MUL | NULL    |                |
| winner      | int(11)  | YES  | MUL | NULL    |                |
| date        | datetime | NO   |     | NULL    |                |
+-------------+----------+------+-----+---------+----------------+

Now the rounds table is a bunch of rounds with specified date ranges, and games are set within the round date range (but not always). Anyways, What I want to do is select all games between multiple round intervals. So if I have three round intervals,

round 1 - nov 13 to nov 15
round 2 - nov 20 to nov 25
round 3 - dec 1 to nov 10

how do I only select the games that are between those date periods without doing multiple SQL statements. Essentially I want something like this in the end:

SELECT * 
FROM games 
WHERE date BETWEEN round1.start_date AND round1.end_date OR
      date BETWEEN round2.start_date AND round2.end_date OR
      date BETWEEN round3.start_date AND round3.end_date

but I don’t know how many rounds I will have. I also cannot use a max a min because there might be rounds between those intervals that I do not want. Right now my only solution is that I do one select for all the rounds, then do a select for each interval through PHP. I am hoping that there might be a better, more efficient way to accomplish this.

Hopefully this made sense and thanks!

Update:

After posting this question, I had an idea of a query like this:

SELECT * 
FROM games INNER JOIN 
     rounds ON games.`date` BETWEEN rounds.start_date AND rounds.end_date

does something like that make sense? It seems to work, but I’ve never joined like that, so I don’t know what type of effects I might encounter.

  • 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-18T01:25:37+00:00Added an answer on May 18, 2026 at 1:25 am

    You were pretty close with your update…

    select `games`.* from games join rounds on (`games`.`date` < `rounds`.`end_date` AND `games`.`date` > `rounds`.`start_date`);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have two MediaWikis, one a slightly older version than the other. I
I currently have a message system which writes to two tables, sent and received
My database has two tables, question and field. Questions may have many fields, and
I currently have two text boxes which accept any number. I have a text
All, I currently have two projects that are under SourceSafe that I am unable
I currently have an asp.net website hosted on two web servers that sit behind
I have two tables that were built for two disparate systems. I have records
I have two tables: 1. tableA is a list of records with many columns.
I need to query the database by joining two tables. Here is what I
I currently have an SQL query which is currently called multiple times like this

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.