Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 799

Salesforce Object Query Language (SOQL), modeled on SQL, for accessing information saved in the Salesforce database.

4 votes

SOQL execution order

https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_VLSQ.htm In no particular order: Don't believe, apply a debug log and experiment ;), fire off your batch and check th …
eyescream's user avatar
  • 24.2k
8 votes

how to compare time only from Datetime field in SOQL

Check the list of date functions and date literals. Something like this? SELECT Id, Name, SystemModstamp FROM Account WHERE SystemModStamp = THIS_MONTH AND HOUR_IN_DAY(SystemModstamp) >= 14 …
eyescream's user avatar
  • 24.2k
0 votes

Semi join sub-selects are not allowed with the 'OR' operator

apex:page's readOnly="true" probably won't help you. All the LIKE look as if they are the reason of timeouts, not only the size of Set of Ids.. A SOSL query might be better in your case and you can s …
eyescream's user avatar
  • 24.2k
5 votes
Accepted

SOQL - how to find duplicate AccountTeamMembers on each account

Aggregate queries do not give you full result set by design. You should apply LIMIT clause for a start or query from Apex calling queryMore() / using for loop However something like that should get y …
eyescream's user avatar
  • 24.2k
1 vote

Combining 2 resultset of "Find" in soql

SOSL reference mentions bit complex examples like FIND {MyProspect AND "John Smith" OR MyCompany} so if you're going through same object I suspect you could rewrite your search to a simpler form. Can …
eyescream's user avatar
  • 24.2k
0 votes

I am executing the below SOQL to get list of all upload documents today from Content Documen...

No, you probably don't have all relevant permissions. There's special "Query All Files" permission. Create a permission set with it and assign to yourself.
eyescream's user avatar
  • 24.2k
0 votes

SOQL Issue, Please correct me, I am getting 'Unknown error parsing query'

SELECT AccountId, Id, FirstName, LastName FROM Contact WHERE Account.Sic = '6752' Read up about relationships, for example https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/s …
eyescream's user avatar
  • 24.2k
12 votes

Count a grouped by SOQL

Something like this? SELECT Name, COUNT(Id) FROM Search_Term__c GROUP BY Name ORDER BY COUNT(Id) DESC LIMIT 5 (assuming you're storing the searched phrases in Name field) Here's whole SELECT refer …
eyescream's user avatar
  • 24.2k
3 votes

SOQL query for text in the middle of text

When in doubt - discard the "cloud magic" and think about it as an Oracle database ;) If the text field's length is less or equal 255 characters (text/textarea type) you can use it in WHERE clause or …
eyescream's user avatar
  • 24.2k
6 votes

SOQL: Accessing Contact Email Addresses through Junction Object

Go "up" on Contact: SELECT (select Contact__c, Contact__r.Email from Distribution_List_Junctions__r ) FROM Distribution_List__c WHERE Name = 'Distribution List 1'
eyescream's user avatar
  • 24.2k
5 votes
Accepted

is it possible to assign all subquery results to a list of subquery objects?

List<Detail_Object__c> details = [SELECT Id, Name FROM Detail_Object__c WHERE Lookup_to_Master__c IN :trigger.new]; No need to even extract the Ids into Set with trigger.newMap.keyset(); bind variab …
eyescream's user avatar
  • 24.2k
0 votes

Handling a Query Zero Results

The results of the query are blank (there's a difference between having a list with 0 rows, with 1 null row in it or the list not even existing. List<Account> accounts = [SELECT Id, Name, LogoID__c F …
eyescream's user avatar
  • 24.2k
2 votes

Non selective query

It's hard to say something without knowing how your data is structured... Can you use smaller LIMIT clause? I doubt it's actually helping in anything. Is this query within start() or execute()? Can …
eyescream's user avatar
  • 24.2k
1 vote

Build String Similar To That is Allowed in Database.query

Binding variables like that to SQL / SOQL ("prepared statements") is a common method to protect yourself against SQL injections plus it's a performance benefit. …
eyescream's user avatar
  • 24.2k
2 votes
Accepted

Number of Records using SOQL query?

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm At the moment - 50K in total. This might be limited further for example if you'll query large textarea fields and run …
eyescream's user avatar
  • 24.2k

15 30 50 per page