WHERE Clause & Filtering SQL Topic exerciseEasyVerified answerSQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

Find Employees by Name Prefix

Find employees whose first name begins with J.

  • Filtering

Exercise brief

Understand the request

HR data coordinator The employee directory needs a prefix search for first names.

Return employees whose first name begins with the letter J.

Return

  • Return first_name, last_name in this exact left-to-right order.

Constraints

  • Use a prefix pattern; characters after the initial J may vary.

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

employees

  • first_nameVARCHAR(50)
  • last_nameVARCHAR(50)

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

LIKE evaluates a text pattern, and `%` can represent any remaining characters.

Hint 2

Anchor the required letter at the beginning of the pattern and place the multi-character wildcard after it.

Hint 3

SELECT first_name, last_name FROM employees WHERE first_name LIKE /* prefix pattern */;

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT first_name, last_name FROM employees WHERE first_name LIKE 'J%';

Why this works

A trailing `%` lets LIKE match any first name that begins with the required prefix, including a one-character name. User-supplied `%` or `_` characters are an edge case and must be escaped when they should be treated literally. PostgreSQL LIKE is case-sensitive, while SQLite, MySQL, and SQL Server behavior depends on configuration or collation; use ILIKE or normalized operands when the requirement is case-insensitive.

Success check

Every returned first name starts with J.

Expected result

Use this output to verify values, aliases, ordering, and row count.

first_namelast_name
JohnDoe
JaneSmith

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.