ODBC Driver for Salesforce

Using SOQL Queries - ODBC Driver for Salesforce



Using SOQL Queries with ODBC Driver

You can use the Salesforce Object Query Language (SOQL) with our ODBC driver to query Salesforce data. SOQL is an optimized version of SQL specifically designed for accessing the underlying Salesforce database. It doesn't support some of the SQL advanced features like wildcards and joins, but allows using filters along with the SELECT clause to return an optional set of data.

The main difference between SQL and SOQL is that the latter is intended exclusively for querying the Salesforce database rather than modifying data with INSERT or UPDATE statements. Also, traditional SQL is used for retrieving data from one or more tables, either related or not, whereas SOQL is used for retrieving data only from Salesforce related objects. The SELECT clause of a SOQL query doesn't allow the wildcard — you must mention all the fields to select. Additionally, you must prefix the query with SOQL: to make the ODBC driver aware that you want to use the SOQL syntax, as in the following query.

SOQL:SELECT Contact.FirstName, Contact.Account.Name FROM Contact

Querying Salesforce Relationships

As mentioned earlier, SOQL doesn't support the JOIN keyword — instead it uses the parent-to-child and child-to-parent relationships in Salesforce. Below are SQL and SOQL queries which are equivalent.

[SQL]

SELECT Contact.Name, Contact.Email, Account.Name 
FROM Contact 
LEFT JOIN Account ON (Contact.AccountId = Account.Id)

[SOQL]

SOQL:SELECT Name, Email, Account.Name FROM Contact

See Also

SOQL Reference
© 2015-2022 Devart. All Rights Reserved. Request Support ODBC Forum Provide Feedback