0

当用户输入数据时,我需要在 mysql 中预订会议室开始日期和结束日期的日期+时间类型,值以这些格式存储 2013-10-03 14:30:00 到 2013-10-03 16:30 :00(开始和结束日期)以及房间号(例如:2)也被存储。

现在假设用户再次创建了一个新条目,

1)same time and and same booking room ( start_date : 2013-10-03 14:30:00 to end_date: 2013-10-03 16:30:00)
2)different time and same booking room (start_date:2013-10-03 13:30:00 to end_date: 2013-10-03 15:30:00)
3)different time and same booking room (start_date:2013-10-03 15:30:00 to end_date: 2013-10-03 18:30:00)

在上述所有情况下,我应该错误地说这个时间不可用,因为它已经预订了。

到目前为止我所做的是:

SELECT  * FROM    calendar WHERE `Room_no`='2' and (StartTime BETWEEN $start_date AND '$start_date' OR EndTime BETWEEN $start_date AND $end_date)

在此先感谢。我是 php 和 mysql.so 的新手。所以如果我犯了任何错误,请告诉我。

4

1 回答 1

0

At first it's very difficult to know what your exact problem is.

Look at the query below. You are using between query between same variable names $start_date and '$start_date'.

SELECT * FROM calendar WHERE Room_no='2'
AND (StartTime BETWEEN $start_date AND '$start_date') OR (EndTime BETWEEN $start_date AND $end_date)

I think you have wrong sql.

于 2013-10-07T07:24:00.633 回答