Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How do I build a string for database query Salesforce?

Asked by Arun Singh Sep 23, 2022 1.3K views 1 answer
Share

About this question

for an extension controller of a VF page, I need to build a query to retrieve all the leads with a Company name similar to a variable. My variable name is compagnia: Now I'm trying to build the query like this:

String query='select Id,Company from Lead where Company like'+ '%'+compagnia'%'

List l=Database.query(query);

But the query doesn't work. How Can I solve this problem?

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.