- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在数据库中有一个下表。
id | list_id |venue_id |name | start_date | end_date |start_time | end_time
1 | 1 | 1 |asdf | 2019-02-02| 2019-02-28 |05:30 |10:00
2 | 7 | 2 |awed | 2019-02-10| 2019-02-20 |07:30 |14:00
3 | 7 | 1 |mjgd | 2019-02-04| 2019-02-13 |09:30 |18:00
现在,我必须在 2019-02-04
和 2019-03-01< 之间找到
。所以我使用了下面的查询。venue_id=1
的开始日期和结束日期
SELECT * FROM `batch_list` WHERE `venue_id` = 1 and ((start_date between '2019-02-04' and '2019-03-01') OR (end_date between '2019-02-04' and '2019-03-01'))
现在我必须找到 venue_id=1 的日期和时间,范围是 2019-02-04
和 2019-03-01
和 05:00
到 18:00
。所以我尝试了下面的查询
SELECT * FROM `batch_list` WHERE `venue_id` = 1 and ((start_date between '2019-02-04' and '2019-03-01') OR (end_date between '2019-02-04' and '2019-03-01')) and((start_time <= `end_time`) and (`start_time` between '05:00' and '18:00')and (end_time between '05:00' and '18:00'))
所以到目前为止没有问题。
我的时间是 05:00
到 20:00
然后我得到与 venue_id 1 相关的所有记录但是如果我改变时间10:00
到 13:00
然后我没有得到记录。
我需要查明该范围内是否有可用的开始时间和结束时间。如果找到,则检查开始日期和结束日期。
你能帮我解决这个问题吗?
模型
function fetchBatches($venue_id,$new_batch_start_date,$new_batch_end_date,$new_batch_start_time,$new_batch_end_time)
{
$where="batch_venue_id='$venue_id' and ((start_date between '$new_batch_start_date' and '$new_batch_end_date')OR (end_date between '$new_batch_start_date' and '$new_batch_end_date')) and ((start_time<=end_time) and (start_time < '$new_batch_start_time' and start_time < '$new_batch_end_time'))";
$result =$this->db->select('*')
->from('batch_list')
->where($where)
->get()
->result();
if ($result) {
return $result;
}
else{
return 0;
}
}
最佳答案
正如一些人所建议的,最好将日期和时间合并到数据库中。
对于你的问题,我想你想要的查询是这个:
SELECT * FROM batch_list
WHERE venue_id = 1
AND (start_date <= '2019-03-01')
AND (start_time <= '13:00:00')
AND (end_date >= '2019-02-04')
AND (end_time >= '10:00:00')
关于php - 如何找到 start_time 和 end_time 范围,如果在范围内找到然后检查 start_date 和 end_date,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54485305/
我从 Facebook Insights API 请求数据,粒度设置为一天,让我们以点赞为例。我的要求是:PAGEID/insights/page_fan_adds_unique/day 响应看起
我正在 2 个带有 #start_time 和 #end_time id 的文件上使用 jQuery 时间选择器插件 ( https://github.com/trentrichardson/jQue
我有一张像这样的 table start_time end_time 2016-10-26 08:45:00 2016-10-27 09:45:00 2016
我有一个名为“activity”的 MySQL 表,其中包含事件数据。重要的列是“start_time”和“end_time”,其中包含字符串(YYYY-MM-DD)来表示事件的开始和结束时间。 我想
我的项目使用的是 laravel 6 和 mysql 5.7,我在模型中放置了两列 start_time 和 end_time ,并且都在 timestamp 类型。在操作中,我创建一条记录并初始化
我在模型中有 start_time 和 end_time 数据字段,我想在 start_time 晚于 end_time end_time: raise forms.Valid
如何获得开始时间和结束时间之间的半小时差异 $('#OutletEvents_start_time').datetimepicker({ datepicker:false, forma
CREATE TABLE seckill ( `seckill_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '商品库存id', `name` VARC
这里一定有一些简单的东西被忽略了...... 我一直在尝试各种方法来创建基本的 IceCube 计划 ( https://github.com/seejohnrun/ice_cube )。总体目标是使
我在数据库中有一个下表。 id | list_id |venue_id |name | start_date | end_date |start_time | end_time 1
假设这是我的数据框: date start_time end_time 1/1/2018 20:00 21:00 1/1/2018 23:00 1
我正在制作时间表提交/批准功能,目前正在处理 pending.php 页面,经理/管理员可以转到 pending.php 并查看待审核的时间表... 我现在的代码是: list($qh,$num) =
我有一个 end_time,我想为 end_time.utc - Time.now 创建一个计时器。但是,当我减去该值时,我得到一个类似 23510.29642 的 float ,我发现它表示小时、分
我是一名优秀的程序员,十分优秀!