SalesforceTrailhead
  • Today
© 2026 Salesforce, Inc. All rights reserved. Privacy Terms of Use Trust Accessibility Cookie Preferences
Apex Basics & Database

Write SOSL Queries

+500 Points~40 minsHands-On Challenge
Apex Basics & DatabaseWrite SOSL Queries

Org:Mindful Goat Playground

Topics

  • Concepts
  • Hands-On Challenge

Looking for help?

Explore Help ResourcesShare Your Feedback
Learning Objectives

After completing this unit, you'll be able to:

  • Describe the difference between SOSL and SOQL.
  • Search across objects with SOSL.

Concepts

SOSL searches text across many objects at once. Use it when you know the words but not where they live; use SOQL when you know the object and the fields.

Hands-On Challenge

  1. Create a class ContactAndLeadSearch with a static method searchContactsAndLeads(String name).
  2. Return a list of lists with matching contacts and leads.
List<List<SObject>> found = [FIND :name IN NAME FIELDS RETURNING Contact(FirstName, LastName), Lead(FirstName, LastName)];
Check ChallengeDemo check
Previous UnitWrite SOQL QueriesBack to Badge Apex Basics & Database