简体   繁体   English

在时间范围内搜索

[英]search within time ranges

I'm trying to come up with a way to query within a list of time ranges, to assign jobs to different people according to their availability. 我正在尝试提出一种在时间范围内进行查询的方法,以便根据他们的可用性将工作分配给其他人。

So I'm imaging a table stored in MYSQL: 因此,我想像一下存储在MYSQL中的表:

Person       | Available (day) | Available (hours) | Free (from) | Free (until)
Mateluna     | Monday          | 10:00 - 13:00     | 10:00       | 13:00
Mateluna     | Monday          | 15:00 - 19:00     | 15:00       | 19:00
DelloStritto | Tuesday         | 12:00 - 18:00     | 12:00       | 18:00
DeFranco     | Monday          | 10:00 - 11:30     | 10:00       | 11:30
Richardson   | Monday          | 08:00 - 10:30     | 08:00       | 10:30

* Where Free (from) and Free (until) would be generated from the Available (hours) *从可用时间(小时)中生成免费(从)和免费(直到)

The idea is that I could create a form that would query the table with parameters like "Monday" & "10:00 - 11:30" and the function would return DeFranco and Mateluna. 我的想法是,我可以创建一个表单,该表单将使用“ Monday”和“ 10:00-11:30”之类的参数查询表,并且该函数将返回DeFranco和Mateluna。 From what I can think of, it would involve having to do a search within "Available (day)" and to be able to search within the "Available (hours)" time ranges - which I do not know how to do or sure if is possible. 从我的想法来看,这将涉及到必须在“可用(天)”内进行搜索,并且必须能够在“可用(小时)”内进行搜索-我不知道该怎么办或不确定是可能的。

At the moment I could create something that works, but it comes out to be more generic, eg. 目前,我可以创建一些可行的方法,但是它变得更加通用。 I can search for "Monday" and see all people available on Mondays and then I'd have to look through the output list to find the people who fit my needs, eg. 我可以搜索“星期一”,然后看到星期一有空的所有人员,然后我必须浏览输出列表以找到适合我需求的人员,例如。

Mateluna @ 10:00 - 13:00
DeFranco @ 10:00 - 11:30
Richardson @ 08:00 - 10:30

Any help, much appreciated on how I could approach this problem, I have a feeling it might involve having to store the information differently, but I'm not sure. 任何帮助,我如何能解决这个问题大加赞赏,我有一种感觉,它可能涉及具有不同的存储信息,但我不知道。

I think for your purpose you can use the 'AND' or 'joins' in the query.... for example 我认为出于您的目的,您可以在查询中使用“ AND”或“ joins”。

select * from db_name where available(day) =%s AND available hours between %s and %s; 从db_name中选择*,其中available(day)=%s AND%s和%s之间的可用时间;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM