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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:35:57+00:00 2026-06-06T12:35:57+00:00

EDIT To simplify this further. Let’s take a look at this structure: Table1: idProduct

  • 0

EDIT To simplify this further.

Let’s take a look at this structure:

Table1: idProduct (int) | Name (varchar)

Table2: idDay (int) | idProduct (int) | date_start(datetime) | date_end (datetime)

idProduct is a common column in both tables. Table two contains data similar to this:

0, 2, 11/22/2012, 11/22/2012
1, 2, 11/23/2012, 11/23/2012
2, 2, 11/24/2012, 11/24/2012
3, 2, 00/00/0000, 11/25/2012
4, 2, 11/25/2012, 00/00/0000

Note that date_start, date_end or both may be all zeroes, in which case this upper or lower limit is considered unbound/unlimited.

In the above case I would like to select idProduct with ID 2 ONLY if today’s date is between the period – earliest date in date_start and latest date in date_end.
If date_start is 00/00/0000 always return the product BUT if date_end is in the future. The reverse applies for date_end being all zeroes and date_start being set. If both columns are zeroes return the product.

  • 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-06T12:35:59+00:00Added an answer on June 6, 2026 at 12:35 pm

    I don’t see the “LEFT JOIN” requirement in your question : just in your title. So

    SELECT t1.idProduct, t1.Name
    FROM table1 t1
    INNER JOIN table2 t2 ON t1.idProduct = t2.idProduct
    WHERE DATE(t2.date_start) < DATE(NOW())--this will also take values with DATETIME = 0000
    AND (DATE(t2.date_end) > DATE(NOW()) OR YEAR(t2.date_end) = 0)
    GROUP BY t1.idProduct, t1.Name
    

    or if you want to check if product has at least one start_date smaller than today (or 0) and at least one end_date bigger than today(or 0), even if start_date and end_date don’t share the same idDay :

    SELECT t1.idProduct, t1.Name
    FROM table1 t1
    WHERE t1.idProduct IN
        (SELECT t2.IdProduct
        FROM table t2
        GROUP BY t2.IdProduct
        HAVING 
        MIN(t2.date_start) <= DATE(NOW()) AND 
        (MAX(t2.date_end) >= DATE(NOW()) OR YEAR(MAX(t2.date_end)) = 0))
    

    It will take :

    min start_date = 0 and max end_date = 0

    min start_date = 0 and max end_date >= today

    min start_date <= today and max end_date =0

    min start_date <= today and max end_date >= today

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

Sidebar

Related Questions

Can you simplify this Math.Ceiling expression decimal total decimal? quantity, multiplier int? days total
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT : It turned out that this can only be done through an external
Edit I've been able to simplify the reproduction of the error: When trying to
Edit: Taking dennmat's suggestion into consideration, I have managed to simplify my image acquiring
EDIT: I've completed rephrased the question as I've been able to simplify my problem
edit: Ok, to put this in a question, I'm asking for possible ways I
EDIT : I think I should clarify my intent... I'm trying to simplify the
This is something that I was exploring to see if I could take what
I'm going to simplify this question. I have a jqgrid instance which posts an

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.