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
RmcnultyRmcnulty 

Relationship Query

Hi,
 
I'm having trouble joining 2 tables. I want to get the Account details from the opportunity.
 
My Query:
 
$query = "SELECT Opportunity.Id, Opportunity.Name FROM Opportunity, Account WHERE Opportunity.AccountId = Account.Id";
 
Result:
MALFORMED_QUERY: WHERE Opportunity.AccountId = Account.Id ^ ERROR at Row:1:Column:96 unexpected token: Account.Id
Best Answer chosen by Admin (Salesforce Developers) 
Park Walker (TAGL)Park Walker (TAGL)
The problem could have to do with the fact that PHP, by default, caches the parsed WSDL in your temp directory. Deleting the cached copy can be a real help when trying to use a new version of the WSDL.

All Answers

SuperfellSuperfell
relationship queries are not SQL joins, I suggest you start by reading the section in the docs on relationship queries.
RmcnultyRmcnulty
I had also tried that:
 
From the Documentation:
SELECT Name, (SELECT LastName FROM Contacts) FROM Account
 
 
Result:
PHP Fatal error:  Uncaught SoapFault exception: [sf:MALFORMED_QUERY] MALFORMED_QUERY: SOQL statements can't query related data in /path/SforceBaseClient.php:471
SuperfellSuperfell
Looks like you're not using the 1.1 toolkit.
RmcnultyRmcnulty
I am, I downloaded the php5-1.1.1.zip yesterday
SuperfellSuperfell
For some reason, you're using an old API version, you need to be on at least API v8.0 for relationship queries.
RmcnultyRmcnulty
It would appear that the WSDL connects to V8.0 however the beta toolkit is supposed to connect to V 9.
SuperfellSuperfell
Something is causing it to connect to an older api version, get a wire capture to confirm.
jmsnyderjmsnyder
I was scratching my head over this problem for a while too. It turned out I first connected using the older wsdl and toolkit version, and then after correcting the wsdl and toolkit I continued to connect using cached connection parameters with the outdated information.  When I tried again the next day a new connection was established with the correct information, and the newer api worked.
Park Walker (TAGL)Park Walker (TAGL)
The problem could have to do with the fact that PHP, by default, caches the parsed WSDL in your temp directory. Deleting the cached copy can be a real help when trying to use a new version of the WSDL.
This was selected as the best answer