# Write a SOSL query to search for the string 'Universal' across Account, Contact, and Lead returning specific fields from each object (FIND 'Universal*' IN ALL FIELDS RETURNING Account(Id, Name), Contact(Id, LastName, Email), Lead(Id, Company)).

**Topic:** Development · **Difficulty:** Medium · **Asked at:** Infosys, Wipro, TCS, Accenture · **Tags:** sosl, scenario, search

Read it on the site: https://www.forcechallenges.com/interview-questions/write-a-sosl-query-to-search-for-the-string-universal-across-account-contact-and-lead-returning-specific

## Answer

SOSL searches text across multiple objects and returns a list of lists, one per object in the `RETURNING` clause.

```apex
List<List<SObject>> results = [FIND 'Universal*' IN ALL FIELDS
    RETURNING Account(Id, Name), Contact(Id, LastName, Email), Lead(Id, Company)];
List<Account> accs = (List<Account>) results[0];
List<Contact> cons = (List<Contact>) results[1];
List<Lead> leads = (List<Lead>) results[2];
```
The `*` is a wildcard; use `IN NAME FIELDS` to limit the search scope.

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