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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:39:24+00:00 2026-05-22T22:39:24+00:00

I am a little rusty on my SQL and am having a little trouble

  • 0

I am a little rusty on my SQL and am having a little trouble with my SQL query. Here is my current query:

 SELECT DISTINCT restriction FROM restrictions 
 WHERE id = ? AND start_date 
 BETWEEN TO_DATE(?, 'yyyy/mm/dd') and TO_DATE(?, 'yyyy/mm/dd') ;

The question marks are being set depending on a user defined parameter, but that should not matter here. So here I am getting any restriction between two particular date, and this works fine. I need to add another condition to this though. Something like:

OR start_date < TO_DATE(?, 'yyyy/mm/dd') and end_date is NULL;

I know what I have here is incorrect, but it should give you an idea…..I want all of the above conditions (the one in the first code snippet), and I want it to also to grab any restrictions that have a start date previous to the first ‘?’, and have a corresponding end_date that is null (second code snippet). I believe this can be done in one SQL query, any help is appreciated, and if you have questions, please ask.

  • 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-22T22:39:25+00:00Added an answer on May 22, 2026 at 10:39 pm
    SELECT DISTINCT restriction 
    FROM restrictions   
    WHERE id = ? 
        AND (start_date BETWEEN TO_DATE(?, 'yyyy/mm/dd') and TO_DATE(?, 'yyyy/mm/dd')
            OR start_date < TO_DATE(?, 'yyyy/mm/dd') and end_date is NULL); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, my SQL knowledge is little rusty. I am trying to generate a report
My C++ is a little rusty having worked in Java and C# for the
a little rusty from my Scheme days, I'd like to take 2 lists: one
I'm a little lot rusty with my SQL and this is driving me nuts.
My SQL is a little rusty and JPQL is entirely new to me. I
My SQL is a little rusty and was just curious if there is a
My php is a little rusty but this is boggling my mind right now.
I am a little rusty with QT but I've had to use it for
I'm coding in vb.net, and I haven't in forever so I'm a little rusty
Little trouble in using css, in the below code, i have used odd and

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.