2014-10-17 88 views
0

我怎樣才能在Salesforce SOQL查詢合併這兩請求轉換成1個單個請求在iOS設備上:如何從兩個表1個查詢在Salesforce SOQL iOS的選擇

NSString *theRequest = [NSString stringWithFormat:@"SELECT Name, OpportunityID FROM OpportunityLineItem where OpportunityID = '%@'", [companyDic objectForKey:@"Id"]]; 
SFRestRequest *request = [[SFRestAPI sharedInstance] requestForQuery:theRequest]; 
[[SFRestAPI sharedInstance] send:request delegate:self]; 

NSString *theRequest2 = [NSString stringWithFormat:@"SELECT CompetitorName FROM OpportunityCompetitor where OpportunityID = '%@'", [companyDic objectForKey:@"Id"]]; 
SFRestRequest *request2 = [[SFRestAPI sharedInstance] requestForQuery:theRequest2]; 
[[SFRestAPI sharedInstance] send:request2 delegate:self]; 

回答

0

使用此子查詢:

SELECT Name, OpportunityID FROM OpportunityLineItem where OpportunityID IN (SELECT OpportunityID FROM OpportunityCompetitor where OpportunityID = '%@')

+0

嘗試過的代碼,但它給了我一個錯誤 – 2014-10-17 09:46:18

+0

錯誤| SFNetworkOperation | callDelegateDidFailWithError外部查詢的where表達式中的左操作數字段應該是與select匹配的id字段,不能使用:'OpportunityID' – 2014-10-17 09:47:35

+0

@AldrinEquila:我已與數據庫進行了交叉檢查,它應該完美地工作。 – Kampai 2014-10-17 09:59:50