WHERE Clause
In MySQL, the WHERE clause is used to filter the rows returned by a SELECT, UPDATE, or DELETE statement. It allows you to specify a condition that must be met for a row to be included in the result set.
Syntax
The basic syntax of a WHERE clause in a SELECT statement is as follows:
SELECT column1, column2
FROM table_name
WHERE condition;Example
Suppose we have a Products table as show below:
Image scaled to 70%
and we want to retrieve the records of a specific category:
SELECT * FROM Products
WHERE category = 'Electronics';Database Exercise
Database Schema:
-- Database schema would be rendered hereExercise Script:
-- Exercise script would be rendered hereAvailable actions: Execute
The result of this query would be a table showing the following rows:
Image scaled to 70%
Last updated on