function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Carlton BanksCarlton Banks 

Problems with relationship query

I cannot get this to work.  I can query each field seperately but together I get errors.  Can someone please
tell me what I am doing wrong?
 
 
Code:
//connect to salesforce
    $client = new SforcePartnerClient();
    $client->createConnection($wsdl);
    $loginResult = $client->login($userName, $password);


$string = "SELECT Description, (SELECT TrackingNumber__c FROM Opportunity) FROM OpportunityLineItem";

$response = $client->query($string);
$queryresult = new QueryResult($response);   

 
foreach($queryresult->records as $result)
{    

  $Description = $result->fields->Description;
  $TrackingNumber = $result->fields->TrackingNumber__c;
   
      echo "Description: " . $Description . "<br />";
      echo "Tracking Number: " . $TrackingNumber . "<br /><br /><br />";

}    

 
EricVlachEricVlach
I'm not a SOQL query expert, but at least in MySQL you can't do it that way - try using JOIN instead...

details from the MySQL docs: http://dev.mysql.com/doc/refman/5.0/en/join.html

Edit: on second though, JOIN might not be the answer... why don't you want to do two seperate queries? store the result of the first query in a var, then input the var in your second query... pretty fool proof.


Message Edited by EricVlach on 01-08-2009 05:50 PM
SuperfellSuperfell
Opportunity is not a child of LineItem, its the other way around, so you want

SELECT Description, Opportunity.TrackingNumber__c FROM OpportunityLineItem