I need some input on my query. What I am attempting to do is compare a time entered by the user to a block of times stored in a database to check to see if that time slot is available.
我需要一些关于我的查询的输入。我试图做的是将用户输入的时间与存储在数据库中的时间块进行比较,以检查该时隙是否可用。
The problem I am running into however is the user's value is in one table and the block of values in another table. My query is below. Any help would be appreciated. I have exhausted all my ideas!
然而,我遇到的问题是用户的值在一个表中,而另一个表中的值块。我的查询如下。任何帮助,将不胜感激。我已经用尽了所有的想法!
EmpID = FOREIGN KEY
EXAMPLE:
User Enters - 2016-04-06 09-00-00 (of type date time in DB) I then run what I thought was this query below and see if there is a time block available between lets say 2016-04-06 09-00-00 AND 2016-04-06 10-00-00
用户输入 - 2016-04-06 09-00-00(数据库中的日期时间类型)然后我运行我认为是下面的查询,看看是否有时间块之间可以说2016-04-06 09- 00-00和2016-04-06 10-00-00
I then update that time as being OK to be scheduled.
然后我将该时间更新为可以安排。
UPDATE TimeRequestedTable
SET AppointTime = "inputed by user"
WHERE EmpID IN
(SELECT BlockTimesTable.EmpID
FROM BlockTimesTable
WHERE
(SELECT AppointTime
FROM TimeRequestedTable)
BETWEEN startTime and EndTime);
1 个解决方案
#1
1
Seems you need an inner join update
似乎您需要内部联接更新
UPDATE TimeRequestedTable
INNER JOIN BlockTimesTable ON BlockTimesTable.EmpID = TimeRequestedTable.EmpID
SET AppointTime = "inputed by user"
WHERE AppointTime BETWEEN startTime and EndTime
#1
1
Seems you need an inner join update
似乎您需要内部联接更新
UPDATE TimeRequestedTable
INNER JOIN BlockTimesTable ON BlockTimesTable.EmpID = TimeRequestedTable.EmpID
SET AppointTime = "inputed by user"
WHERE AppointTime BETWEEN startTime and EndTime