Salesforce interview questions and answers : All about SOQL : Part 1
Que 1. What is replacement of SELECT * in SOQL?
Ans 1. SELECT FIELDS(ALL) FROM Account.
SELECT FIELDS(STANDARD) FROM Account
SELECT FIELDS(CUSTOM) FROM Account
* Can not add duplicates fields in select statement
Que 2. Which standard objects acts as Junction object ?
Ans 2.
1. OpportunityLineItem
2. OpportunityContactRole
3. CaseSolution
4. CaseArticle
5 PriceBookEntry
Que 3. What is FOR UPDATE in SOQL?
Ans 3. FOR UPDATE is used for - prevent race conditions
- thread safety problems
e.g. Account[] accts=[Select Id from Account limit 2 FOR UPDATE];
To lock records,records can't be modified by other user either through code or UI.
Que 4. What are types of SOQL queries?
Ans 4.
1. Parent to Child (Inner query)
When we want to get related child records from for a particular parent records or set of parent record then we use concept of inner query.
e.g. SELECT Id,Name,(SELECT Id,Name from Contacts ) From Account where Id in :accList
2. Child to Parent
Sometimes we want to fetch Parent records while working on child records then we go for child to Parent query
e.g SELECT Id,AccountId,Name,Account.ShippingAddrerss From Contact
Que 5. Write SOQL query to Select All Contacts from Contact object where FirstName is equal to LastName.
Ans 5.
Comments
Post a Comment