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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:40:09+00:00 2026-06-09T21:40:09+00:00

So I have an existing Mysql query that is pretty intense as-is which goes

  • 0

So I have an existing Mysql query that is pretty intense as-is which goes something like:

SELECT CURRENT.*, PROGRAMS.NAME 
FROM CURRENT 
LEFT JOIN PROGRAMS ON CURRENT.PID = PROGRAMS.ID 
ORDER BY PID ASC

Now, I want to use this query to do something else since I’m already hitting my database. I have a third table called “TIMEWINDOWS”, how would I use this query to return a set of tinyint (0 or 1) based on whether or not it’s between the Start_Time and End_Time along with all the other stuff already in my query?

Thanks a lot for the help.

The TimeWindows table has the following stuff:

ID               int(11) PK
PID              int(11)   <-- Can join on this from any of the other tables.
ALL_DAY          tinyint(1)
START_DATE       date
END_DATE         date
EARLIEST   time
LATEST     time
NOTICE       int(11)
LATEST  time
MAX int(11)
MIN int(11)
PROBABLE_START   time
PROBABLE_END     time

I want to check if it’s between start & end date, and return a bool if it is but I can’t seem to find a way to do so, can anyone help?

  • 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-06-09T21:40:11+00:00Added an answer on June 9, 2026 at 9:40 pm
    SELECT CURRENT.*, PROGRAMS.NAME, 
      CASE WHEN t.ID IS NULL THEN 0 ELSE 1 END AS BetweenStartEnd
    FROM CURRENT 
      LEFT JOIN PROGRAMS ON CURRENT.PID = PROGRAMS.ID 
      LEFT JOIN TIMEWINDOWS t ON (t.PID = CURRENT.PID 
        AND DATE_FORMAT(NOW(), '%Y-%m-%d') > START_DATE 
        AND DATE_FORMAT(NOW(), '%Y-%m-%d') < END_DATE
      )
    ORDER BY PID ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following MYSQL query: SELECT categories.key, categories.name, count(*) as itemsCount FROM categories
I have an existing mysql query that I need to add to and I'm
I have a legacy PHP/MySQL app that calls mysql_connect(). Tons of existing downstream code
I have a connection class for MySQL that looks like this: class MySQLConnect {
I have an existing SQL query that works fine in SQL Server, that I
I have an existing database in mysql. One of my tables has discontinuous ids.
I have an existing application (with MySQL DB). I just got a new requirement
I have existing code that uses CMNewProfileSearch to find then iterate over the color
I have existing Linux shared object file (shared library) which has been stripped. I
I have existing java code and need to create Design Document based on that.

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.