首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在访问查询中的日期间搜索

在访问查询中的日期间搜索
EN

Stack Overflow用户
提问于 2022-03-30 15:17:01
回答 2查看 41关注 0票数 0

我正在做我的顶点项目,我正在为一个记录跌倒、虐待和行为事件的设施建立一个数据库。我想让用户能够在日期范围内根据特定的条件进行搜索,但是我在查询方面遇到了一些问题。

此示例用于MRN函数的搜索,其中用户可以输入病人的MRN,以查看记录中的所有事件(跌倒、行为、虐待)。我希望有一个日期搜索集成到MRN搜索。以下是我到目前为止提出的问题:

代码语言:javascript
复制
SELECT DemographicsTable.MRN, DemographicsTable.[First Name], DemographicsTable.[Last Name], [Abuse Table].[Date of Event], [Abuse Table].[Staff Name(s)], [Abuse Table].Unit, [Abuse Table].Shift, [Abuse Table].Location, [Abuse Table].[Other Location], [Abuse Table].Incident, [Abuse Table].[Abuse Type], [Abuse Table].[Other Abuse Type], [Abuse Table].[Unsubstantial/ Substantial], [Abuse Table].Description, [Abuse Table].Medications, [Abuse Table].Diagnoses, [Abuse Table].Behaviors, [Abuse Table].Intervention
FROM DemographicsTable 
INNER JOIN [Abuse Table] 
ON DemographicsTable.MRN = [Abuse Table].MRN
WHERE ((([Abuse Table].[Date of Event]) Between Forms!DMVAForm!frmSearches!searchByMRNForm!txtStartDate And Forms!DMVAForm!frmSearches!searchByMRNForm!txtEndDate Or Forms!DMVAForm!frmSearches!searchByMRNForm!txtStartDate Is Null)) And ((DemographicsTable.MRN)=forms!DMVAForm!frmSearches!searchByMRNForm!cbMRN) Or (((DemographicsTable.MRN)=forms!DMVAForm!frmSearches!searchByMRNForm!cbMRN))
ORDER BY DemographicsTable.MRN;

表单仍然编译,但是它为病人的MRN选择所有记录,而不仅仅是日期之间的记录。我以前在一个简单的搜索中使用了“中间”函数,它起了作用,所以我不知道问题是什么。

谢谢你的帮助!

EN

回答 2

Stack Overflow用户

发布于 2022-03-30 18:46:13

在两个日期之间工作,Between (dateA and dateB)。如果您有其他的范围,我建议您使用

代码语言:javascript
复制
Where( Between(dateA and dateB) or Between(dateC and dateD) or....)
票数 0
EN

Stack Overflow用户

发布于 2022-04-02 13:29:51

试试这个:

代码语言:javascript
复制
SELECT 
    DemographicsTable.MRN, 
    DemographicsTable.[First Name], 
    DemographicsTable.[Last Name], 
    [Abuse Table].[Date of Event], 
    [Abuse Table].[Staff Name(s)], 
    [Abuse Table].Unit, 
    [Abuse Table].Shift, 
    [Abuse Table].Location, 
    [Abuse Table].[Other Location], 
    [Abuse Table].Incident, 
    [Abuse Table].[Abuse Type], 
    [Abuse Table].[Other Abuse Type],
    [Abuse Table].[Unsubstantial/ Substantial], 
    [Abuse Table].Description, 
    [Abuse Table].Medications, 
    [Abuse Table].Diagnoses, 
    [Abuse Table].Behaviors, 
    [Abuse Table].Intervention
FROM 
    DemographicsTable 
INNER JOIN 
    [Abuse Table] 
    ON DemographicsTable.MRN = [Abuse Table].MRN
WHERE 
    (([Abuse Table].[Date of Event] Between Forms!DMVAForm!frmSearches!searchByMRNForm!txtStartDate And Forms!DMVAForm!frmSearches!searchByMRNForm!txtEndDate) Or (Forms!DMVAForm!frmSearches!searchByMRNForm!txtStartDate Is Null)) 
    And 
    ((DemographicsTable.MRN=forms!DMVAForm!frmSearches!searchByMRNForm!cbMRN) Or (DemographicsTable.MRN=forms!DMVAForm!frmSearches!searchByMRNForm!cbMRN))
ORDER BY 
    DemographicsTable.MRN;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71679876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档