WHERE

SQL WHERE Keyword

The WHERE clause filters a result set to include only records that meet a specified condition. It is commonly used with SELECT, UPDATE, and DELETE statements.

  • Text values must be enclosed in single quotes (‘value’).
  • Numeric values must not be enclosed in quotes.

Tutorials dojo strip

SQL WHERE Syntax

SQL

SQL WHERE with Text Value Example

This query selects all female patients (gender = ‘F’).

SQL

SQL WHERE with Numeric Value Example

This query selects the patient with patient_id = 1.

SQL

SQL WHERE Supported Operators

You can use the following operators in the WHERE clause:

OperatorDescription
=Equal
<> or !=Not equal
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal
BETWEENBetween a certain range
LIKESearch for a pattern
INTo specify multiple possible values

SQL WHERE with Operator Example (BETWEEN)

This query selects patients with patient_id between 3 and 6.

SQL

SQL WHERE Labs

Tutorials dojo strip