function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Keith Stephens 18Keith Stephens 18 

soql query with inline text

I am needing to include a string of text in my soql query. Is this possible?
In sql server the following query works and returns the text, but how do I do this using SOQL?

SELECT [LastModifeidDate]
   'hello world'
  FROM [ERP].[dbo].[Cases]
Purushotham YellankiPurushotham Yellanki
Hi Keith,

I don't think Salesforce SOQL supports using plain text in your queries. You can always use Dynamic Soql to pull data and below is a Dynamic Soql example that pulls Id, Name with couple of other fields from Account and again here I am using my field Api names that are stored in text1 and text2 variables.

String text1 = 'Text_Field_1__c';
String text2 = 'Text_Field_2__c';

String qry = 'Select Id, Name, ' + text1 + ', ' + text2 + ' From Account Limit 22';
List<Object> lstRcds = Database.query(qry);  

System.debug('************' + lstRcds);

Salesforce Documentation is the best reference guide:

Thank you