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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:49:22+00:00 2026-06-01T20:49:22+00:00

Can i get some help to clean up following query and possibly convert it

  • 0

Can i get some help to clean up following query and possibly convert it to joins.

SELECT pd.id, pd.title, pd.vacation_type_ids, pd.auto_vacation_theme
FROM property_details pd
WHERE pd.company_id =247
AND pd.status =  "active"
AND pd.id NOT 
IN (
    SELECT d.property_id
    FROM property_discount d
    WHERE (
    (
    d.start_date <= CAST(  "2012-04-15" AS DATE ) 
    AND d.end_date >= CAST(  "2012-04-15" AS DATE ) 
    AND d.start_date <= CAST(  "2012-04-17" AS DATE ) 
    AND d.end_date >= CAST(  "2012-04-17" AS DATE )
    )
    OR (
    d.start_date >= CAST(  "2012-04-15" AS DATE ) 
    AND d.start_date <= CAST(  "2012-04-17" AS DATE )
    )
    OR (
    d.end_date >= CAST(  "2012-04-15" AS DATE ) 
    AND d.end_date <= CAST(  "2012-04-17" AS DATE )
    )
)
)

I am not an expert with MySQL so sorry if i have did something wrong

  • 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-01T20:49:24+00:00Added an answer on June 1, 2026 at 8:49 pm

    This whole thing makes no sense to me.

    WHERE (
    (
    d.start_date <= CAST(  "2012-04-15" AS DATE ) 
    AND d.end_date >= CAST(  "2012-04-15" AS DATE ) 
    AND d.start_date <= CAST(  "2012-04-17" AS DATE ) 
    AND d.end_date >= CAST(  "2012-04-17" AS DATE )
    )
    OR (
    d.start_date >= CAST(  "2012-04-15" AS DATE ) 
    AND d.start_date <= CAST(  "2012-04-17" AS DATE )
    )
    OR (
    d.end_date >= CAST(  "2012-04-15" AS DATE ) 
    AND d.end_date <= CAST(  "2012-04-17" AS DATE )
    )
    )
    

    The first block can get reduced to basically start_date <= '2012-04-17' AND end_date >= '2012-04-17'. This case gets handled by the second and third block which is basically start_date BETWEEN '2012-04-15' AND '2012-04-17' respectively end_date BETWEEN '2012-04-15' AND '2012-04-17'.

    Do you really want an OR between this, or rather an AND?

    You gave no information about your DB design, so I can only guess, if the following connection between these two tables is right.

    SELECT pd.id, pd.title, pd.vacation_type_ids, pd.auto_vacation_theme
    FROM property_details pd
    INNER JOIN property_discount d ON pd.id = d.property_id
    WHERE pd.company_id =247
    AND pd.status =  'active'
    (
    d.start_date BETWEEN '2012-04-15' AND '2012-04-17' /*this is right when start_date is of type date, when it's datetime or timestamp you better write '2012-04-17 23:59:59', otherwise '2012-04-17 00:00:00' is assumed, which is basically not considering this date*/
    OR
    d.end_date BETWEEN '2012-04-15' AND '2012-04-17'
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am curious if I can get some help with Open Graph since I
I can not get logs from some customers, can I use Google Urchin in
this is a bit of a newbie question but hoping I can get some
how can i get some part of string (in symbols). For example: $string =
How can I get some part of string that I need? accountid=xxxxxx type=prem servertime=1256876305
Where can I get some explanations on what F1 , F2 , F3 ,
where can i get some references about SPL predefined constants like SELF_FIRST , CHILD_FIRST
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
i am trying to get some data, but i dont know how can i
I need to get one page (can be cURL, or filegetcontent), get some info

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.