# SQL WHERE Clause

### The SQL WHERE Clause

The WHERE clause is used to filter records.

The WHERE clause is used to extract only those records that fulfill a specified condition.

#### WHERE Syntax

```sql
SELECT column1, column2, ...
FROM table_name
WHERE condition;
```

> &#x20;**Note:** The WHERE clause is not only used in SELECT statement, it is also used in UPDATE, DELETE statement, etc.!

> ### Demo Database

&#x20;Below is a selection from the "Customers" table in a sample database:

![](https://826093633-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LS8lPNzCGPR5-DLbGXv%2F-LSDq34kJwZXzsPN2BW_%2F-LSDqjLo9Jo0h3f9_p5F%2Fimage.png?alt=media\&token=20473681-f24b-4b52-bc4b-012ab3130c4e)

### WHERE Clause Example

The following SQL statement selects all the customers from the country "Mexico", in the "Customers" table:

```sql
Example
SELECT * FROM Customers
WHERE Country='Mexico';
```

Text Fields vs. Numeric Fields

SQL requires single quotes around text values (most database systems will also allow double quotes).

However, numeric fields should not be enclosed in quotes:Example

```sql
SELECT * FROM Customers
WHERE CustomerID=1;
```

### Operators in The WHERE Clause

The following operators can be used in the WHERE clause:

![](https://826093633-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LS8lPNzCGPR5-DLbGXv%2F-LSDq34kJwZXzsPN2BW_%2F-LSDtOZWyHv_AEmdxLBB%2Fimage.png?alt=media\&token=d068c921-eac4-49d7-945b-2f3608ada815)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gyansetu-sql.gitbook.io/sql-programming/sql-select/sql-where.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
