SQL クエリに問題があります
これが私のクエリです:
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)))
問題は、2 番目select
が null を返すと、次のエラーが表示されることです。
#1241 - Operand should contain 1 column(s)
誰でも私を助けることができますか?
EDIT
このクエリを実行すると、select
理由がわかりませんが、2 番目の行を含む行も含めてすべての行が表示されます。
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')))