系统间缓存编码查询 [英] Intersystems Cache coding query

查看:92
本文介绍了系统间缓存编码查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT Distinct visitid As Visit_ID, 
       AreaId->FacilityID As Facility_ID, 
       visitid-PatientSecondaryNumber As Patient_MRN, 
       visitid->PatientName As Patient_Name, 
       visitid-statustext As visit_Status, 
       visitid->LastVisitTypeID->shortname As visit_Type,
       visitid-LastVisitActivationTime As Last_Visit_Activation,
       (SELECT VisitConversionID->VisitTypeID-shortname 
        FROM qcpr_arf_OC.VisitActivationTime 
        WHERE visitid = qcpr_arf_RG.AreaBedHistoryEventTime.visitid AND 
              VisitConversionID->VisitTypeID-shortname LIKE 'Emergency%' ) AS Last_Visit FROM qcpr_arf_rg.AreaBed INNER JOIN qcpr_arf_RG.AreaBedHistoryEventTime ON     
       qcpr_arf_rg.AreaBed.AreaBedID = qcpr_arf_RG.AreaBedHistoryEventTime.AreaBedID 
WHERE AreaBedHistoryEventTimeSubID LIKE 'Ç910%' AND visitid <> ''

您好上述查询已由前一位员工保留,我正在尝试找出

Hi the above query Have been retain by a previous employee and I'm trying to figure out what "->" means could anyone please help me out.

推荐答案

以扩展@Ben的答案并提供更多信息

To expand on @Ben's answer, and to include more information in this thread rather than just the external link he supplied.

->语法是Cache SQL的简写,表示在属性是引用的情况下的隐式LEFT OUTER JOIN

-> syntax is a Cache SQL shorthand that represents an implicit LEFT OUTER JOIN in cases where a property is a reference to another table.

作为示例,您的SQL查询在SELECT子句中包含以下列:
AreaId-> FacilityID As Facility_ID
此表达式等效于LEFT OUTER JOIN,其中AreaId使用 ON {table.ROWID} = AreaID 引用该表,如果存在AreaId,则返回该FacilityID;如果存在,则返回NULL

As an example your SQL query includes the following column in the SELECT clause: AreaId->FacilityID As Facility_ID This expression is equivalent to a LEFT OUTER JOIN with the table that AreaId references using ON {table.ROWID} = AreaID, and returning that FacilityID if such an AreaId exists, or NULL if it does not.

乍一看,语法可能没有多大意义,但可以减少查询中SQL的数量。就是说,如果您对visitid进行明确的JOIN操作,则可能更容易执行此查询。

At first glance, the syntax may not make much sense, but it can reduce the amount of SQL in a query. That said, this query might be easier to follow if you made the JOIN on visitid explicit.

我包括@Ben到InterSystems文档的链接: http://docs.intersystems.com/cache20141/csp/ docbook / DocBook.UI.Page.cls?KEY = GSQL_specialfeatures#GSQL_specialfeatures_impjoin
文档的重点是从OO的角度描述该功能的行为,并给出一些基本的查询重写,以说明功能。

I am including @Ben's link to the InterSystems documentation: http://docs.intersystems.com/cache20141/csp/docbook/DocBook.UI.Page.cls?KEY=GSQL_specialfeatures#GSQL_specialfeatures_impjoin The focus of the documentation describes the behaviour of the feature from a more OO perspective, as well as giving some basic query rewrites illustrating the feature.

这篇关于系统间缓存编码查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆