Salesforce Decode
Salesforcedecode
Back to questions
ApexBeginnersoqlqueries

What is SOQL and how is it different from SQL?

Real World Scenario

You need Accounts in California with open Opportunities. The interviewer asks how you query in Apex.

Expected Answer

• SOQL is Salesforce Object Query Language for reading records from the database • Syntax resembles SQL SELECT but only supports SELECT, not arbitrary UPDATE/DELETE in queries • Relationship queries traverse parent-child in one statement using dot notation • SOQL is case-insensitive on field names and returns sObject lists or query locators • Use selective filters on indexed fields to avoid long-running queries

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

A query that filters on indexed fields so Salesforce scans fewer rows—typically under 10% of object rows or with selective filters on Id/external id.

Architect Perspective

Mention selective queries when discussing SOQL— juniors often stop at SELECT syntax.