How can i use select * in SOQL query in Salesforce?
Asked Answered
C

1

5

I am trying to run a select in Salesforce as follows:

     SELECT [Account].* FROM [Account] WHERE [Account].Id IN ('123456789012345678')

but gives an error: "Unknown error parsing query" How can i do this selection ?

Chalcopyrite answered 10/2, 2021 at 1:40 Comment(0)
A
11

SOQL is not SQL. The SQL syntax you're using here is not valid in Salesforce. You can learn the basics of SOQL in the Write SOQL Queries unit on Trailhead or the SOQL and SOSL Reference.

Until the Spring '21 release of Salesforce, there is no support for a SELECT * wildcard. You must spell out all fields explicitly. Once your org is upgraded to Spring '21 (the release is in progress as of this writing), you'll be able to use FIELDS(ALL). At that point, your query would look like this:

 SELECT FIELDS(ALL) FROM Account WHERE Id IN ('123456789012345678') 

Note that you must be using API version 51.0 to connect to Salesforce in order to use this function. You may return up to 200 records.

Aundreaaunson answered 10/2, 2021 at 4:29 Comment(2)
thanks for the update. In further reading it looks like as of February 12: All Orgs will now be on Spring ’21!Chalcopyrite
Note that if the object has more than 200 fields you may get an error.Nonentity

© 2022 - 2024 — McMap. All rights reserved.