在 mysql ph 中查找讲师空闲时间 [英] find instructor free times in mysql ph
本文介绍了在 mysql ph 中查找讲师空闲时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 mysql 中有一个这样的表:
I have a table in mysql like this:
+------------+------------+------------+------------+
| user_id | inst_id | date_start | date_end |
+------------+------------+------------+------------+
| 20 | 1 |1375344000 |1375351200 |
+------------+------------+------------+------------+
它尝试了大约 20 个查询,但无法想出在任何给定范围时间内获得 inst_id 结果的想法.例如我想知道从 2013-08-01 8:00
到 2013-08-01 10:00
it tried about 20 queries but couldn't come up with an idea to get inst_id result within any given range time.
for example i want to know which inst_id
are available from 2013-08-01 8:00
to 2013-08-01 10:00
推荐答案
你的代码可能是这样的
$time_start = strtotime( '2013-08-01 8:00' );
$time_end = strtotime( '2013-08-01 10:00' );
$sql_query = mysql_query( 'SELECT * FROM `table` WHERE `time` > '.$time_start.' && `time` < '. $time_end .'; );
您也可以使用 UNIX_TIMESTAMP
命令在 SQL 查询中完成所有操作.
Also you could do it all in SQL query with UNIX_TIMESTAMP
command.
这篇关于在 mysql ph 中查找讲师空闲时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文