我正在尝试识别一些在MS Access的时间范围以外访问系统的用户的任何活动。
我有两个桌子。
Table 1: Log
----------
userid
date/time ------------- DATE TIME Format they accessed
location -------------- where they accessed (full URL format)
Table 2: Schedule
-----------
system URL ------------ Subdomain URL
window start ------- TIME format
window end --------- TIME format
window day (days of the week when this window is applicable) - 1 - 7 where 1 is Sunday and 7 is Saturday.
我该如何过滤掉以识别那些在窗口时间之外访问系统的用户?
答案 0 :(得分:0)
您将要使用内部联接使用SQL查询
--This line selects the fields that we want to take from the first table
SELECT table1.userID, table1.accessTime, table1.systemURL
FROM table1
INNER JOIN
--where the urls are the same
ON table2.systemURL = table1.systemURL
--compare the dates to see if it accessed outside of the window
WHERE table1.accessTime<=table2.windowStart Or table1.accessTime>=table2.windowEnd;
但是请下次让我们知道您尝试过什么
答案 1 :(得分:0)
根据所提供的有限信息,我可能会提出类似的建议:
select
t1.userid,
t1.[time they accessed],
t1.[where they accessed]
from
log t1 inner join schedule t2 on
t1.[where they accessed] = t2.[system URL]
where not
t1.[time they accessed] between t2.[window start] and t2.[window end]
您可能还需要针对[window day]
进行测试,但是我不确定如何在您的数据库中实现它。