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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:45:04+00:00 2026-05-17T18:45:04+00:00

I have been trying to wrap my head around this issue but I am

  • 0

I have been trying to wrap my head around this issue but I am not making much progress. My goal is to do a left join between two tables with criteria for the right table. I would like to see the list of all products and prices for the current day even though there is no pricing row for the current day. Here is an example of the code:

SELECT products.id, products.name, prices.price
FROM products LEFT JOIN prices
ON products.id = prices.id
WHERE prices.date = CURRENT_DATE

This produces only the products with price information for the current date.

OK, so that is just the first part of my issue. I would eventually like to pull the price for CURRENT_DATE + INTERVAL 1 DAY as well.

Any information would be greatly appreciated.

  • 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-17T18:45:05+00:00Added an answer on May 17, 2026 at 6:45 pm

    Assuming PRICES.date is a DATETIME data type, use:

       SELECT pd.id, 
              pd.name, 
              pr.price
         FROM PRODUCTS pd
    LEFT JOIN PRICES pr ON pr.id = pd.id
                       AND DATE(pr.date) = CURRENT_DATE
    

    I used the DATE function to remove the time portion, because CURRENT_DATE won’t include the time portion while DATETIME records will.

    In this example, the date criteria is being applied before the JOIN is made. It’s like a derived table, filtering down the information before the JOIN is made — which’ll produce different results than if the criteria was specified in the WHERE clause.

    To get the list of products and prices for tomorrow, use:

       SELECT pd.id, 
              pd.name, 
              pr.price
         FROM PRODUCTS pd
    LEFT JOIN PRICES pr ON pr.id = pd.id
                       AND DATE(pr.date) = DATE_ADD(CURRENT_DATE, INTERVAL 1 DAY)
    

    Reference:

    • DATE_ADD

    If you want both todays and tomorrows prices in a single query, use:

       SELECT pd.id, 
              pd.name, 
              pr1.price AS price_today,
              pr2.price AS price_tomorrow
         FROM PRODUCTS pd
    LEFT JOIN PRICES pr1 ON pr1.id = pd.id
                       AND DATE(pr1.date) = CURRENT_DATE
    LEFT JOIN PRICES pr2 ON pr2.id = pd.id
                       AND DATE(pr2.date) = DATE_ADD(CURRENT_DATE, INTERVAL 1 DAY)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to wrap my head around this issue for the past
I've been trying to wrap my head around solving this issue but I can't
I have been trying to wrap my head around why this is happening but
I've been trying to wrap my head around this issue: How to create a
I have been trying to wrap my head around this for a while now
Ok, I have been trying to wrap my head around this http live streaming.
I've been trying to wrap my head around this issue for the last hours
I have been trying to wrap my head around this FXCop violation DoNotDeclareReadOnlyMutableReferenceTypes MSDN:
I've been trying to wrap my head around this particular issue for two days
I have been trying to wrap my head around the concept of semaphores in

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.