- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在做订票系统
让我尝试解释一下我需要什么。我有一个表格,其中包含旅行日期、人数、起点、终点、机票类型和返回日期。门票可以是单程票、一日票或往返票(买家可以选择返程日期)。
问题是,假设 5 个人在 2013 年 12 月 21 日购买了目的地 A 到 B 的机票,但他们都购买了日票,这意味着他们都将在同一天返回,而目的地将是 B 到 A 的地点返回时间。
还有一个人买了2013年12月21日的票,但是从目的地B到A,我需要人数总数为6。
我还在机票上生成一些条形码,因此如果买家选择每日票或往返票,我需要两个查询,一个用于计算开始日期的人数(预订)总数,第二个用于计算返回日期。
所以基本上表格看起来像这样
id | date | persons | paid | destinationA | destinationB | typeofticket |return_date
--+----------+----------+------+--------------+--------------+--------------+----------
1 |21.12.2013| 5 | yes | 1 | 2 | daily |21.12.2013
2 |21.12.2013| 1 | yes | 2 | 1 | one-way |21.12.2013
2 |21.12.2013| 2 | no | 2 | 1 | one-way |21.12.2013
那么有什么建议吗?我的查询应该是什么样子?我有这样的东西(这显然是错误的):
$query1 = "
SELECT date, SUM(persons) totalpersons FROM table_name
WHERE date='$date' AND (destinationA ='$destinationA') OR
(destinationA ='$destinationB' AND typeofticket = 'Daily')
";
$query2 = "
SELECT date, SUM(persons) totalpersons FROM table_name
WHERE date='$return_date' AND (destinationA ='$destinationA') OR
(destinationB ='$destinationA' AND typeofticket = 'Daily')
";
如果名称中的某些字符串不正确,那是因为我在这篇文章中将字段名称从我的语言翻译成英语:(
我只是在寻找一些关于如何处理此查询的提示......提前致谢。
这是正在运行的自动取款机,但我 100% 确定我仍然缺少一些东西:),是的,我需要查询以仅查看付费门票:
$query_b1 = "
SELECT date, SUM(persons) totalpersons FROM table_name
WHERE date='$date' AND paid='yes' AND (destA='$destA' AND destB='$destB' OR
(destB='$destA' AND typeofticket ='Daily')
)";
最佳答案
我认为你所得到的实际上是正确的,减去一个拼写错误(你有“='Daily'”而不是“='daily'”)。这是我的版本:
SELECT `date`, SUM(persons) as totalpersons
FROM table_name
WHERE `date`='$date'
AND (
(destinationB > destinationA)
OR (destinationA > destinationB AND typeofticket='daily')
)
为了清楚起见,将目的地列重命名为 origin
和 destination
也是一个好主意,并将地名放入字段中。因此您的查询将如下所示:
SELECT `date`, SUM(persons) as totalpersons
FROM table_name
WHERE `date`='$date'
AND (
(
origin = '$origin'
AND destination = '$destination'
)
OR (
origin = '$destination'
AND destination = '$origin'
AND typeofticket='daily'
)
)
您可以只使用此查询两次,但切换回程的出发地和目的地。
关于php - mysql中的机票预订查询,基于日期、目的地和返回日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20713703/
我正在为一家小型酒店开发预订系统。我非常擅长 PHP,但不太擅长 SQL...我制作了一个表格,您可以在其中输入您的信息、房间数量并使用日历选择到达日期和退房日期。 现在一切都很顺利,直到我不得不检查
我有一个租车脚本。我把汽车放在汽车 table 上。我将所有预订信息保存在预订表中。预订表有开始日期和结束日期字段以及 car_id 字段。 例如:car_id: 14, from="2014-06-
我最近被问及一个关于假设的基于 Web 的预订系统的面试问题,以及我将如何设计数据库架构以最大限度地减少重复并最大限度地提高灵 active 。 用例是管理员将属性的可用性输入系统。可以设置多个时间段
如何在 中使用标签式标题预订 像 RMarkdown 一样? 在 RMarkdown 中: # heading1 {.tabset} ## tab1 content1 ## tab2 content2
我使用 Woothemes booking对于我的 woocommerce 网站 当我为产品建立自定义搜索时,我还必须搜索可用性,这是我应该如何管理来自 B.O 的可用性以及插件如何存储到数据库 a:
我正在尝试找到一种在亚马逊中按 ISBN 查找书名的简单方法。我正在协助我 child 的学校做一个简单的 list 。我的测试集中的很多书籍都无法使用其他来源(尝试使用 Google、WorldCa
我正在使用 JQuery-Mobile 在浏览器中开发一个房间预订应用程序。最初,我将预订建模为带有时间戳的记录和带有持续时间的字段。 现在,如果我有一个表/div,每个表代表一天的 15 分钟,那么
我有一个自托管 NancyFX Web 服务器的桌面应用程序。作为一个桌面应用程序,我们需要允许动态 IP 地址,因此我们使用 netsh 的通配符选项注册了 url,如下所示: netsh http
我有一个关于 x++ 和循环内容的问题要问。首先,这是代码: class MixFor5 { public static void main(String[] args) { int x = 0;
我在为带有等候名单的预订类型系统设计算法时遇到困难。 在任何给定时间都可以有 3 个活跃插槽,每个插槽持续一个月,之后它们将被放入等待列表中。我希望能够插入项目从等待状态转为事件状态的日期。 我知道三
我正在制作一个 session 室预订系统,您可以在其中选择特定的时间段,然后您应该在那时获得可用的房间。一些表的名称是法语,因此我将在需要时提供 () 之间的含义。我的问题是,当我选择时间时,我什至
我开始了一个新项目: 我只运行以下命令: rails g model subscription 然后: rails g controller subscriptions 然后: 已将resources
我正在通过一个 api 发布一个现场预订请求。当我通过一个表单操作发布数据并提交时,我会得到回复。但是当我试图通过 curl 发布相同的 url 以获得响应时,我没有得到任何数据。 网址是:- htt
已结束。此问题不符合 Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的非现场资源的问题对于 Stack Overflow 来说是无关紧要的
我想知道有用的资源/书籍,它们将有助于初学者学习网络服务器、应用程序服务器和网络架构基础知识。 我正在尝试了解不同的服务器如何相互交互。浏览器如何向服务器发送请求以及服务器如何发送响应。我有兴趣了解这
我正在开发一个项目,用户可以在餐厅进行预订,但仅限于餐厅允许的日期。餐厅还可以设置特定时间有多少个座位。 因此,餐厅可以提供每周格式的时间表,但也可以提供异常(exception)情况(例如假期)。
我正在尝试为以下计划改进 SQL: 看起来像这样: - @users.each do |user| - @dates.each do |date| %td - Booking.
我正在使用 WooCommerce 预订插件,我目前希望在预订摘要(产品选项)中显示其他信息。 为此,我使用了以下钩子(Hook):woocommerce_admin_booking_data_aft
请让我了解保留所有 ec2 实例时 ssd 的费用,那么为什么每 GB 月会扣除 0.10 美元? 我已经保留了 c4.2xlarge 和 m4.xlarge 实例,但仍然会从账单中连续扣除费用,仅针
我想知道是否有办法使用 Woocommerce 预订自动设置可预订产品的开始日期和结束日期。我想要实现的是,当用户进入我的产品页面时,开始日期和结束日期(月、日和年)将根据我希望通过 Jquery 设
我是一名优秀的程序员,十分优秀!