Lab 03 – Lab Manual
Database Systems – Lab 03
WHERE clause:
The WHERE clause in SQL is used to filter records from a table based on specified conditions.
It allows users to retrieve only those rows that meet certain criteria, reducing the amount of
data retrieved and making queries more efficient.
SYNTAX: SELECT column1, column2, ...
FROM table_name
WHERE search_condition;
The search_condition is a combination of one or more expressions using the comparison
operator and logical operator. The SELECT statement will include any row that satisfies the
search_condition in the result set.
When executing a SELECT statement with a WHERE clause, MySQL evaluates the WHERE
clause after the FROM clause and before the SELECT clauses:
WHERE Statement with Comparison Operators:
The following comparison operators can be used in the where clause to make the search
condition:
Comparison Operators
= Equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
<> Not equal to
Example Statements:
mysql> SELECT * FROM shipment WHERE destination = "London";
mysql> SELECT * FROM shipment WHERE destination <> "London";
1
Database Systems – Lab 03