Questions tagged [query]

A query is an inquiry into the database using the SELECT statement. A query is used to extract data from the database in a readable format according to the user's request.

Filter by
Sorted by
Tagged with
47 votes
3 answers
26k views

Workaround for Offset 2000 limit on SOQL Query

Problem I'm trying to make a standard query pagination. I'm using SOAP API. The logic is classic: LIMIT recordsByPage OFFSET (recordsByPage*pageNumber)+1, It works fine, however, I'm facing the ...
Martin Borthiry's user avatar
13 votes
1 answer
22k views

Query Which Profiles Have Read Access To Specific Object?

Since I couldn't think of how to write this query off the top of my head, I thought it might be worth sharing. How can I query which Profiles have Read permission on a specific object? I knew it would ...
Adrian Larson's user avatar
  • 150k
12 votes
1 answer
762 views

Variable scope - database.query() has access to variables not in scope

I was answering a question and this little inconsistency popped up. Just wondering if anyone has come across it before, or if anyone knows why this happens. A variable that is declared within some ...
Nick C's user avatar
  • 6,553
2 votes
2 answers
6k views

Query Activity Failing

I have set up a data extension to capture a query and return it's results. In order to track the query, I am running it in automation studio. However, the query keeps failing. I have checked that the ...
0xsegfault's user avatar
  • 6,593
0 votes
1 answer
5k views

Query Activity for ORDER BY xxx DESC LIMIT

I'm trying to create a query activity in order to show, from a Data Extension, only the last 5 articles ids. I tried with the formula ORDER BY xxx DESC LIMIT 0,5 as in SQL but it is not working and it ...
M.Giorgio's user avatar
6 votes
1 answer
2k views

Trying to get SymbolTable of an Apex class and get null

I'm quering Apex classes using Tooling API QueryResult queryResult = toolingConnection.query("select Id, ApiVersion, Name, NamespacePrefix, SymbolTable, Body from ApexClass where NamespacePrefix = ...
Liudmila Likhovid's user avatar
3 votes
1 answer
1k views

How to get list of all sobject records modified today in the system?

I need a list of all sobject records that got modified today. this is not just for one object but for all objects in the system. Is there a simpler way to do this?
The Beginner's user avatar
3 votes
1 answer
2k views

External Id in salesforce

I have an external system that needs to update a record in my org. This system only knows the external id, but the problem is that this external id is not unique, e.g. multiple records might have the ...
SFDC's user avatar
  • 668
2 votes
1 answer
2k views

Didn't Understand Relationship - How To Find Child Relationship Name?

I have a many-to many relationship between three objects. LGFProducts, PartsinProducts, and Parts. PartsinProducts is the junction object. I want to be able to get data like the names of the parts ...
user1470901's user avatar
2 votes
1 answer
5k views

What is wrong with this query? (Unknown error parsing query)

When I run the following query in query editor I get this error. Error Unknown error parsing query Query SELECT Id, OwnerId,Account.OwnerId FROM Contact where OwnerId = Account.OwnerId limit 100 ...
Masoud Az's user avatar
0 votes
1 answer
83 views

List has no row exception: Queryerror

I have below line placed in controller that fires list has no row exception. I just need to show a custom message instead when the query returns no value. Apex code: Id CI=[select ...
Testing_SFDC's user avatar
  • 2,940
21 votes
5 answers
60k views

Filtering by Long Text Area field in SOQL

I'm working on a custom search page, which will search through the fields of the Project object. I use dynamic SOQL query similar to that: String query = 'SELECT Name, Status__c ... FROM ...
Hleb's user avatar
  • 397
14 votes
6 answers
67k views

How to query all user with salesforce license?

I want query the list of user with salesforce license List<user> user11=[SELECT name from user limit 5000];
Teja's user avatar
  • 1,422
10 votes
4 answers
11k views

How do I SOSL across objects, matching all records with FIND clause?

To all the expert SOSL gurus lurking out there, I thought this will be an interesting one: I have some SObjects of different types and I want to return their Name values in a single query. In ...
Matt and Neil's user avatar
7 votes
2 answers
3k views

SOSL query returns only 250 records even if there are more than 2000+ records present

I have two queries List<sobject> soslRecords1 = Search.query('FIND {I need help res*} in all fields returning Incident__c (id) where ID IN:rec_ids')[0]; List<sobject> ...
Shilpa's user avatar
  • 71
5 votes
2 answers
5k views

How do we refer Bulk Data Load Jobs in Apex

I have a requirement where, we need to send an Email on the status of failed Bulk Data Load jobs. But I am not sure the Object Name or how to refer those jobs programatically in my APex code. When I ...
Amulya's user avatar
  • 367
0 votes
2 answers
5k views

Soql query for retrieving images from notes and attachments

I want retrieve image from documents in not other notes like pdf,ext... please how to write soql query
user4955's user avatar
16 votes
1 answer
22k views

SOQL to find All Users with a Custom Permission

I was looking for a little help to find all users with a particular Custom Permission assigned to them, either via Profile or Permission Set.
Austin Russell's user avatar
16 votes
1 answer
2k views

How can adding a Subselect make a SOQL query non-selective?

I have a SOQL Query with subquery that fails to execute because it is non-selective. I don't understand why and cannot interpret the results. All I know is that tearing parent und sub query apart ...
Robert Sösemann's user avatar
15 votes
2 answers
27k views

How is a DateTime object formatted into a String suitable for a String based SOQL query?

In order to write a where clause against a datetime field, you need to format your dateTime object into the following format: WHERE SystemModstamp > 2005-10-08T01:02:03Z How do you correctly ...
edgartheunready's user avatar
11 votes
2 answers
21k views

Retrieve globalpicklist/globalvalueset without SOQL

Is it possible to retrieve the values of a Global Picklist/GlobalValueSet using Schema class without a SOQL ?
HSG's user avatar
  • 997
10 votes
1 answer
7k views

SOQL query to fetch records with reserved characters ('*', '/', '(', ')')

Hoping there is a simple answer that I am overlooking. Currently, we are able to search for the following reserved characters with an escape sequence, eg a backslash character '\', in SOSL: & | ! ...
Evelyn Grizzle's user avatar
9 votes
2 answers
3k views

DateTime.Format() Documentation example causes exception

I'm trying to get a DateTime to format into a value to be used in a dynamic query. For some reason, the documentation snippet on how to format a DateTime for a query is giving me an exception. Im ...
battery.cord's user avatar
  • 8,815
8 votes
1 answer
1k views

ORs and ANDs in the retrieve function of Visualforce Remote Objects

Related: OR/AND condition for complex criteria with remote objects Background The retrieve query format allows the use of or and and clauses to create complex queries. The relevant documentation is ...
Charles Koppelman's user avatar
7 votes
2 answers
15k views

Query Chatter Feed, Topics, and Groups

First off, my end goal is lofty and time-consuming, but we need metrics and this is the best way to do it (that I can think of). Originally, a chatter post was created on the quote, case, or where ...
Grant's user avatar
  • 320
6 votes
2 answers
14k views

Inline query has too many rows for direct assignment, use FOR loop

I am receiving an error stated above on line 26**(listAccount1)**, can anyone guide me on how to solve it? public class FRB_UpdateExceptionsforBatch { public static void FRB_Exceptions(){ ...
manchesterunited's user avatar
6 votes
1 answer
2k views

Soql query on parents other child object

I want to write a soql query , My scenario is as follows. I have three objects objectA,objectB,objectC. objectA is the parent object for both objectB,objectC. objectA - objectB (Master-detail ...
Salesforce developer's user avatar
5 votes
2 answers
2k views

Retrieve Force.com registered domain

I need to return this value: Is there anyway to get the registered Force.com domain for a given org, with raw Apex code or Metadata API?
Miguel Lattuada's user avatar
5 votes
1 answer
1k views

Which Tooling API Objects can be queried in Apex?

I would like to know which objects I can query in Apex which are not listed in the SOAP API Developer Guide but are listed in the Tooling API Developer Guide. Is there a list maintained somewhere?
Adrian Larson's user avatar
  • 150k
5 votes
1 answer
960 views

Query Author Apex Permission?

I'm trying to figure out how to query all users who have Author Apex permission (or any other system permissions). I thought it would be straightforward, but I don't see where it would be stored. With ...
Adrian Larson's user avatar
  • 150k
3 votes
2 answers
343 views

Query to Include Child Junction Records - Didn't Understand Relationship

I have a Junction object name AcctContactAff which creates a many-to-many relationship between Contacts and Accounts and stores (among other things) the title of the person at the account. ...
William Haack's user avatar
3 votes
3 answers
12k views

Nested SOQL query?

so, the following query is pretty self explanatory: SELECT p.Accountid, p.Name, (select name FROM Account where id = p.Accountid) FROM Contact p order by accountid' is there any way to do this in a ...
gfppaste's user avatar
  • 845
3 votes
3 answers
2k views

Error when building a interaction SQL Query in Marketing Cloud using a semicolon

Working in Marketing cloud where we are building a query that splits apart data from a single column into 4 separate columns where the delimiter is a semicolon. Error is displayed when doing a "...
Andyw's user avatar
  • 159
2 votes
1 answer
3k views

Aggregated Query Too many query rows

I have this aggregated query which seems to return only 1050 rows but still I am getting a limit exception. This is the APEX query: AggregateResult[] groupedResults = [SELECT COUNT_DISTINCT(ID) cnt, ...
Dedo's user avatar
  • 5,009
2 votes
1 answer
670 views

Optimizing SQL for large volumes

We're working with somewhat large sets of data, around 15M - 35M records per DE, each row with 150+ attributes. What are some ways to optimize SQL queries when handling many records? For an exaple, ...
Rain's user avatar
  • 5,725
1 vote
1 answer
2k views

How to move my SOQL query outside for loop?

Hello I need some help moving my SOQL Query outside of my for loop to maintain best practices. I am using the code below to get the most recent opportunity of a selected account and grabbing the ...
Lavasocks's user avatar
1 vote
0 answers
1k views

Exporting a file from a data extention automation in salesforce marketing cloud

There is a database extension in salesforce marketing cloud that I need to export from the automation. I didn't create the DE and am unsure how to export it for use outside of salesforce marketing ...
Jennifer Luby's user avatar
1 vote
1 answer
2k views

Query NOT IN _Open from JobID .. incl. EmailAddress

In a 2 email marketing campaign, I want to send mail 2 to those who did not open mail 1. I believe I can do this by having an automation query for those who did not open mail 1 and then send them mail ...
Felix Sanchez's user avatar
1 vote
1 answer
1k views

How to use VSCode to find which reports are using a specific field

I have used Eclipse in the past but unfortunately, Eclipse and Force.com IDE no longer work for me. I have switched over to VSCode along with the Salesforce DX and forcecode extensions (among many ...
Dennis's user avatar
  • 49
1 vote
4 answers
9k views

SOQL query for Multiselect picklist

Hello I'm trying to use string in SOQL query where clause for multiselect picklist. I need to get records of CustObj__c where Multipicklist__c fild have 'abc' or 'xyz' values. String str = '\'abc\',\...
Watson's user avatar
  • 199
0 votes
1 answer
4k views

Multiple Sub Query using child parent relationship

Consider in my basket, I have a package (Main Product-just a holder) which will have 2 standalone products (child) and again the standalone products will have child products (Grand Parent). All these ...
user47200's user avatar
0 votes
0 answers
134 views

querying Recently account viewed

How how do I query recent account views and group by LastViewedDate SELECT Id, Name FROM Account ORDER BY Name DESC limit 10 FOR VIEW I used to have it like this, ...
Metawaa's user avatar
  • 709
-1 votes
1 answer
374 views

Too Many Records in salesforce

I have More amount of Records in salesforce, i have created field as not Unique.So for account Records is created with duplicate Records also,I want to check how many Records contain dulplicate ...
SFDC's user avatar
  • 668
-1 votes
1 answer
7k views

How to Query a Data Extension and Update the Subscriber list at the Child Business Unit Level?

How to Query a Data Extension and Update the Subscriber list at the Child Business Unit Level without using landing pages?
user8755's user avatar
  • 185
-1 votes
1 answer
1k views

Parent to child SOQL query is not working

SELECT Id, CurrencyIsoCode, ExpirationDate__c, (SELECT Id, Regional_Starting_Price_2__c FROM SBQQ__QuoteLine__c) FROM SBQQ__Quote__c WHERE ...
Swa's user avatar
  • 21
11 votes
5 answers
13k views

Can a SOQL query selecting all columns be generated at runtime?

It seems like SOQL does not have an equivalent to SQL's "SELECT * FROM ..." (If SOQL has this syntax, show me and I will mark that as the answer.) To get around this limitation, I have been using a ...
edgartheunready's user avatar
11 votes
1 answer
17k views

Make SOQL Case-Insensitive?

I have this query: List<id> accounts1 = [SELECT Id, PersonContactId, PersonEmail, FirstName, LastName, net_Id__pc FROM Account where net_Id__pc = pFederationID] I need ...
Jose's user avatar
  • 383
9 votes
2 answers
2k views

How to query an Installed Package Id

I'm trying to properly build a relative URL from within a managed package context, so that a simple link can be provided to the user to bring them to the assign licenses page specifically for that ...
Brian Miller's user avatar
  • 5,162
8 votes
2 answers
17k views

Didn't understand relationship in FROM part of query call [duplicate]

I am trying to query the child record using the parent record id. I understand that we have to use the child relation name in the inner query to get the child records. select id, (select id from ...
SfdcBat's user avatar
  • 4,781
8 votes
2 answers
6k views

How do I find merged Records?

How do I find the accounts that were merged after the merge operation? Is there any flag being set after the merge process gets completed? For instance, does any field depict that this particular ...
Priyalakshmi's user avatar
  • 1,456