Getting Started

  • What is Trailhead
  • myTrailhead
  • Trailblazer Community
  • Career Growth

Learn

  • Trails
  • Trailmixes
  • Modules
  • Projects

Credentials

  • Superbadges
  • Certifications
  • Maintain Certifications

Salesforce

  • Salesforce.com
  • AppExchange
  • Developers
  • Help Portal
© 2026 Salesforce, Inc. All rights reserved. Privacy Terms of Use Trust Accessibility Cookie Preferences
SalesforceTrailhead
  • Today
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