SQL Exercises

MySQL: SQL WHERE Clause Exercises for Beginners

0 Exercises
~0 min

This guide is specifically for MySQL syntax.

Beginner-level SQL WHERE Clause practice exercises with solutions.

Exercise 1

Question: Select all employees with a salary greater than 50000.

SELECT * FROM employees WHERE salary > 50000;

The WHERE clause filters rows based on a condition. Comparison operators include: =, <>, <, >, <=, >=

Exercise 2

Question: Find employees in the 'Sales' department with salary between 40000 and 60000.

SELECT * FROM employees WHERE department = 'Sales' AND salary BETWEEN 40000 AND 60000;

Use AND to combine multiple conditions. BETWEEN is inclusive of both endpoints.

Exercise 3

Question: Select employees whose names start with 'J'.

SELECT * FROM employees WHERE name LIKE 'J%';

LIKE with % wildcard matches any sequence of characters. 'J%' matches strings starting with J.

Exercise 4

Question: Select employees where the manager_id is NULL (no manager assigned).

SELECT * FROM employees WHERE manager_id IS NULL;

Use IS NULL to check for NULL values. Using = NULL will not work because NULL represents unknown values.


MySQL-Specific Notes

This page covers MySQL syntax. Other databases may have different syntax for similar operations.

Related Content

From Our Blog

Ready for more practice?

Join SQL Mastery and get access to interactive exercises, quizzes, and more.