第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

預(yù)訂檢查空房情況

預(yù)訂檢查空房情況

PHP
慕斯709654 2023-07-01 15:21:55
我正在創(chuàng)建一個(gè)預(yù)訂房間的系統(tǒng)。我需要找出日期范圍內(nèi)的可用房間數(shù)量。退房當(dāng)天房間應(yīng)該可用。到目前為止,我只能找到日期范圍內(nèi)的訂單,但即使是這些訂單也無法正常工作。這有效 2020-06-27 - 2020-07-05這不起作用 2020-06-28 - 2020-07-05目標(biāo)是找出日期范圍內(nèi)的空閑房間數(shù)量,然后提供訂單。我在這里閱讀了很多主題,但沒有想出解決方案。我使用 PHP 和 MySQL-- phpMyAdmin SQL Dump-- version 4.7.4-- https://www.phpmyadmin.net/---- Po?íta?: 127.0.0.1-- Vytvo?eno: Sob 27. ?en 2020, 10:24-- Verze serveru: 10.1.28-MariaDB-- Verze PHP: 7.2.1SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";SET AUTOCOMMIT = 0;START TRANSACTION;SET time_zone = "+00:00";/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;/*!40101 SET NAMES utf8mb4 */;---- Databáze: `rezervace`---- ------------------------------------------------------------ Struktura tabulky `booking_orders`--CREATE TABLE `booking_orders` (  `id` int(11) NOT NULL,  `number` int(11) NOT NULL,  `checkin` date NOT NULL,  `checkout` date NOT NULL,  `first_name` varchar(255) COLLATE utf8_czech_ci NOT NULL,  `last_name` varchar(255) COLLATE utf8_czech_ci NOT NULL,  `email` varchar(255) COLLATE utf8_czech_ci NOT NULL,  `phone` varchar(20) COLLATE utf8_czech_ci NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;---- Vypisuji data pro tabulku `booking_orders`--INSERT INTO `booking_orders` (`id`, `number`, `checkin`, `checkout`, `first_name`, `last_name`, `email`, `phone`) VALUES(74, 0, '2020-06-27', '2020-06-28', '', '', '', ''),(75, 0, '2020-06-27', '2020-06-29', '', '', '', ''),(76, 0, '2020-06-27', '2020-07-01', '', '', '', ''),(77, 0, '2020-06-28', '2020-06-29', '', '', '', '');-- ------------------------------------------------------------ Struktura tabulky `booking_order_room`--
查看完整描述

1 回答

?
斯蒂芬大帝

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超8個(gè)贊

附上我最終使用的解決方案。也許可以采取不同的做法。


DROP TABLE IF EXISTS t1;


CREATE TEMPORARY TABLE t1 as (

SELECT r.name as name, r.id, sum(i.quantity) as qty

FROM booking_orders o

LEFT JOIN booking_order_room i on o.id = i.order_id

LEFT JOIN booking_rooms r on i.room_id = r.id

where

(checkin<'2020-07-17' and checkout>='2020-07-17') -- overlap at the end

OR (checkin<='2020-07-15' and checkout>'2020-07-15') -- overlap at the start

OR (checkin>='2020-07-15' and checkout<='2020-07-17') -- complete overlap

GROUP BY r.id

);


SELECT br.name as name, br.quantity as quantity, br.input as input, br. price as price, t1.qty 

FROM booking_rooms br

LEFT JOIN t1 ON t1.id = br.room_id

ORDER BY br.name DESC


查看完整回答
反對(duì) 回復(fù) 2023-07-01
  • 1 回答
  • 0 關(guān)注
  • 154 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)