2012-09-11 3 views
1

SalesForce Db에 왼쪽 외부 조인을 실행하여 Product2 테이블에서 ID 및 ProductCode 필드를 가져오고, 관련된 경우 (존재하는 경우) PriceBookEntry에서 일부 필드를 가져 오려고했습니다. id = '01sd00000008iWpAAI'인 PriceBook2도 있습니다. 오류가 나에게 돌아SalesForce에 대한 LEFT OUTER JOIN이 작동하지 않습니다.

SELECT Id, ProductCode, 
(SELECT Id, PriceBook2Id, PriceBookEntry__r.Product2Id FROM PriceBookEntry__r 
WHERE PriceBook2Id='01sd00000008iWpAAI') 
FROM Product2 WHERE ProductCode IN 
('151','250','256','270','289') 

은 다음과 같습니다 : 다음은 샘플 쿼리입니다

INVALID_TYPE: PriceBookEntry__r.Product2Id FROM PriceBookEntry 
WHERE PriceBook2Id='01sd00000008iWpAAI') 
^ ERROR at Row:1:Column:89 
Didn't understand relationship 'PriceBookEntry__r' in FROM part of query call. 
If you are attempting to use a custom relationship, 
be sure to append the '__r' after the custom relationship name. 
Please reference your WSDL or the describe call for the appropriate names.. 

내가이 쿼리에 대한 몇 가지 변형을 시도,하지만 성공하지 못했다. Product2 테이블에 이러한 ProductCodes에 대한 행이 있습니다.

내가 무엇을 그리워합니까?

답변

1

해결책을 찾았습니다 : 키가 PriceBookEntry 테이블에 있습니다. 여러 개가 있어야합니다 (PriceBookEntries). 따라서 검색어는 다음과 같아야합니다.

SELECT Id, ProductCode, 
(SELECT Id, PriceBook2Id, Product2Id FROM PriceBookEntries 
WHERE PriceBook2Id='01sd00000008iWpAAI') 
FROM Product2 WHERE ProductCode IN 
('151','250','256','270','289') 
관련 문제