结合两个Salesforce SOQL查询
我在Salesforce中使用两个SOQL查询 第一个查询:从用户中选择Id、FirstName、LastName,其中Id='00000 ADFEDSFSRTGDR' 第二个查询:从UserLogin中选择isfreezed,其中UserId='00000 adfedsfsrtgdr' 我们可以将这两个查询合并为一个查询吗。请在这方面帮助我。否。如果您在结合两个Salesforce SOQL查询,salesforce,soql,salesforce-communities,Salesforce,Soql,Salesforce Communities,我在Salesforce中使用两个SOQL查询 第一个查询:从用户中选择Id、FirstName、LastName,其中Id='00000 ADFEDSFSRTGDR' 第二个查询:从UserLogin中选择isfreezed,其中UserId='00000 adfedsfsrtgdr' 我们可以将这两个查询合并为一个查询吗。请在这方面帮助我。否。如果您在User或UserLogin上使用“description”调用,您将看到它们被链接,但descripe的结果中没有“relationship
User
或UserLogin
上使用“description”调用,您将看到它们被链接,但descripe的结果中没有“relationshipName”字段。这是用来链接的,有点像普通数据库中的表别名
// No going "up"
System.debug(UserLogin.UserId.getDescribe().getRelationshipName());
// And no going "down" either
for(Schema.ChildRelationship cr : User.SObjectType.getDescribe().getChildRelationships()){
if(cr.getChildSObject() == UserLogin.sObjectType && cr.getField() == UserLogin.UserId){
System.debug(cr);
System.debug(cr.getRelationshipName());
}
}
所以你可以
SELECT Id, Name,
(SELECT PermissionSet.Name FROM PermissionSetAssignments)
FROM User
因为PermissionSetAssignment.AssigneeId
具有relationshipName。但不是
SELECT Id, Name,
(SELECT IsFrozen FROM UserLogin)
FROM User
往上走也不行<代码>选择联系人中的帐户名正常,但选择已冻结,用户登录中的用户名
无效。再次-因为描述结果中没有relationshipName
例如,您必须单独查询并在代码中将它们链接为Map
。否。如果在User
或UserLogin
上使用“description”调用,您将看到它们已链接,但descripe结果中没有“relationshipName”字段。这是用来链接的,有点像普通数据库中的表别名
// No going "up"
System.debug(UserLogin.UserId.getDescribe().getRelationshipName());
// And no going "down" either
for(Schema.ChildRelationship cr : User.SObjectType.getDescribe().getChildRelationships()){
if(cr.getChildSObject() == UserLogin.sObjectType && cr.getField() == UserLogin.UserId){
System.debug(cr);
System.debug(cr.getRelationshipName());
}
}
所以你可以
SELECT Id, Name,
(SELECT PermissionSet.Name FROM PermissionSetAssignments)
FROM User
因为PermissionSetAssignment.AssigneeId
具有relationshipName。但不是
SELECT Id, Name,
(SELECT IsFrozen FROM UserLogin)
FROM User
往上走也不行<代码>选择联系人中的帐户名正常,但选择已冻结,用户登录中的用户名
无效。再次-因为描述结果中没有relationshipName
例如,您必须单独查询并在代码中将它们链接为Map