# Write a SOQL query to find all Contacts whose LastName starts with 'S' and ends with 'a'.

**Topic:** Development · **Difficulty:** Easy · **Asked at:** TCS, Infosys, Mphasis · **Tags:** soql, scenario, like

Read it on the site: https://www.forcechallenges.com/interview-questions/write-a-soql-query-to-find-all-contacts-whose-lastname-starts-with-s-and-ends-with-a

## Answer

Use `LIKE` with a prefix and suffix pattern. `%` matches any number of characters, `_` matches exactly one.

```soql
SELECT Id, FirstName, LastName FROM Contact WHERE LastName LIKE 'S%a'
```
Note that LIKE in SOQL is case-insensitive, and a leading wildcard (like `%a`) alone would make the query non-selective.

---
Source: ForceChallenges · last updated 2026-10-19
