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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:35:07+00:00 2026-06-04T04:35:07+00:00

I am having a problem with a sql query Here is my query: SELECT

  • 0

I am having a problem with a sql query

Here is my query:

SELECT `rooms`.*  
FROM `rooms`  
WHERE (`rooms`.`room_id` NOT IN (
    SELECT * 
    FROM `reservations` `res` 
    WHERE ('2012-05-03' NOT BETWEEN res.expected_checkin_date 
    AND res.expected_checkout_date) 
    AND ('2012-05-08' NOT BETWEEN res.expected_checkin_date 
    AND res.expected_checkout_date)))

The problem is that when the second select returns null, it shows the following error:

#1241 - Operand should contain 1 column(s)

Can anybody help me?

EDIT

When I run this query it shows all the rows even the one which includes inside of the second select
I don’t know why?

SELECT `rooms`.*, `type`.*, `status`.* FROM `rooms` INNER JOIN `room_types` AS `type` ON `type`.`room_type_id` = `rooms`.`room_type_id` AND `type`.`num_beds` >= 1 AND type.room_type_id=2 INNER JOIN `room_statuses` AS `status` ON `status`.`room_status_id` = `rooms`.`room_status_id` WHERE (`rooms`.`room_id` NOT IN (SELECT `res`.`room_id` FROM `reservations` `res` WHERE (res.expected_checkin_date >= '2012-05-01' AND res.expected_checkin_date < '2012-05-31') AND (res.expected_checkout_date >= '2012-05-31' AND res.expected_checkout_date < '2012-05-31')))
  • 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-04T04:35:08+00:00Added an answer on June 4, 2026 at 4:35 am

    I imagine you want something like

    SELECT `reservations`.`room_id` FROM `reservations`
    

    for the sub-select, since room_id is what you are matching on with the NOT IN operator.

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

Sidebar

Related Questions

I am having trouble with a SQL query. SELECT t.topicname, m. *, ms.avatar FROM
I am having problems with echoing the result from a sql query as links
I am having an SQL query problem. I am trying to get data in
I am having a problem with my sql query in c#, basically it's inline
We are having a serious problem with a query that defies explanation. In SQL-plus
I am having problem converting my SQL query to LINQ. How would you create
I am basically having the exact same problem as here: SQL View: Join tables
I'm having a problem with an SQL query on a php page. I'm pretty
Here's a real noobish MySQL query problem I'm having. I have a high score
i am having a problem with access sql SELECT statement. the problem is 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.