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

  • Home
  • SEARCH
  • 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 207553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:44:46+00:00 2026-05-11T17:44:46+00:00

I have a MySQL db and inside it a table called ProductMaster with 6

  • 0

I have a MySQL db and inside it a table called ProductMaster with 6 fields “Product_Id,Product_Name,Model,Opening_date,Closing_Date,Status”.
Opening_Date and Closing Date Can accept null values.So some records has values for this field

I have the below query to display records from this table.

"select Product_Id,Product_Name,Model from ProductMaster  where Status=1"

Now I want to change the query to have a filter on the Opening_Date and Closing_Date
if they are not null

Ex : If a Record is having Opening_Date as 05/01/2009 and Closing Date as 05/30/2009
Then i want to check whether today is a date in between these two dates and if Yes ,Returns the records

If both field values are empty, Return Records

Can any one help me to frame the query ? Thanks in advance

  • 1 1 Answer
  • 1 View
  • 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-11T17:44:46+00:00Added an answer on May 11, 2026 at 5:44 pm

    The WHERE part of a query (the “WHERE clause”) is just a long boolean expression. What does this mean? That MySQL just wants it to return either true or false, which it understands as “Yes. Include this row in the results.” or “No. Don’t include this row in the results.”

    If I understand correctly, you want to do two things:

    1. Check if the opening_date and closing_date are null
    2. Check if today is between those two dates.

    And you want #2 to only happen if #1 is true. Which could be expressed like:

    #1 AND #2
    

    Which would be evaluated as false if either #1 or #2 is false.

    That can be translated as:

    1. (opening_date IS NOT NULL) AND (closing_date IS NOT NULL)
    2. NOW() >= opening_date AND NOW <= closing_date

    So if we treat those two like the #1 and #2 in the expression we said we were going to use (#1 AND #2) then we get:

    ((opening_date IS NOT NULL) AND (closing_date IS NOT NULL)) 
    AND (NOW() >= opening_date AND NOW <= closing_date`)
    

    And that’s the WHERE clause you need.

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

Sidebar

Related Questions

I have a MySQL table with approximately 3000 rows per user. One of the
I have a MySQL database table with a couple thousand rows. The table is
I have a MySQL table containing domain names: +----+---------------+ | id | domain |
Anyone knows how to get sum of number? For example i have mysql column
I have a MySQL query that returns a result with a single column of
I have a MySQL database behind a firewall which can only be accessed via
I have a MySQL database of keywords that are presently mixed-case. However, I want
I have two mysql tables, one containing details on cars and one containing all
I have a mysql database which has grown to over 200 tables in it.
I have a MySQL instance running locally on port 3306, but for some legacy

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.