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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:04:56+00:00 2026-05-26T08:04:56+00:00

With this query i will find all apartments that are available. All the available

  • 0

With this query i will find all apartments that are available.
All the available apartments have no booking id.

What i want: When it has a booking id and the status is cancelled I also want the apartment to show up, but i don’t know how to…

  SELECT a.id, a.num_persons, a.rating, a.lat, a.lng, a.street, a.number
      ,c.title, c.introduction, c.text, c.area, c.long_term_rental, c.beds
      , c.features ,c.services_and_equipment, c.terms_and_conditions
      , m.url
    FROM appartments AS a
    INNER JOIN appartments_content AS c on c.parent_id = a.id
    INNER JOIN meta AS m on m.id = c.meta_id
    LEFT JOIN appartments_bookings AS b 
           ON (b.appartment_id = a.id 
          AND NOT ((? > b.departure) OR (? < b.arrival)))    
         --    this ? = arrival     that ? = departure
    WHERE b.id IS NULL 
      AND c.language = ? 
      AND a.hidden = ? 
      AND a.publish_on <= ? 
      AND a.city_id = ? 
      AND a.num_persons >= ? 

    ORDER BY a.num_persons ASC, a.publish_on DESC
    LIMIT ? OFFSET ?'

I added this:

AND b.status != ? OR NOT ((? >= b.departure) OR (? < b.arrival))) WHERE b.order_id IS NULL

But this doesn’t work, i get nog results.

  • 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-26T08:04:57+00:00Added an answer on May 26, 2026 at 8:04 am

    Don’t know mySQL syntax but change your WHERE to clause to something like…

    WHERE (b.id IS NULL OR (b.id IS NOT NULL AND b.status = ‘cancelled’))
    AND c.language = etc etc

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

Sidebar

Related Questions

I want to create a query that will return all Alerts that have a
I will make this quick and simple I have a query and I want
Im trying to write a query that will find and display all of my
I have a long query like this: $a=$this->Signin->find('all', array( 'fields'=> array( ..... ), 'conditions'
self here stands for Contact model. This query will find all completed tasks for
I have a query to find all the phone numbers that match a partial
I have a form where when it was created it will this query public
Also what will be the scenarios where this query is used select * from
in my self-defined module I have this method which will query the db and
I'm trying to create a query using cypher that will Find missing ingredients that

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.