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

How to join two tables together?

Hello all, I am trying to do a simple query like select * from contracts, accounts where contracts.accountid = and its not working. Any ideas why this is not working?

ok, for some reason it looks like that is not supported. Odd.
Has anyone done a client side join and has some examples to share?
It's really 2 (or more) requests to do this join. I'd start with "select Id, , AccountId from Contract". Then, put all of your AccountIds into an array and do a retieve API call passing in the array of Account Ids, a comma separated list of fields to retrive from the Account and the object type to retrieve. In C# it looks something like this (typed from memory):

QueryResults contractResult = binding.Query("Select ID, ContractNumber, AccountId from Contract");
if (contractResults.size > 0)
string [] accountIds = new string [contractResult.size];
for (int i = 0; i < contractResults.size; i++)
accountIds[i] = contractResults.records[i].Id;
sObject [] accounts = binding.retrieve("Id, Name, Phone", "Account", accountIds);