0

I'm trying to do a SOQL query that only queries where the Name from Account is equal to a string being passed.

public void getAcc(String searchField) {
  List<Account> list_acc = [Select Name, ID, LastModifiedByID from Account WHERE Name = searchField ORDER BY LastModifiedDate Asc];
}

This is not working since my syntax is incorrect, but kind of confused on how to check for a specific name being passed into this function

1 Answer 1

2

You're missing the colon that needs to be placed in front of a variable when querying via apex as below:

public void getAcc(String searchField) {
  List<Account> list_acc = [Select Name, ID, LastModifiedByID from Account WHERE Name =: searchField ORDER BY LastModifiedDate Asc];
}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .