> For the complete documentation index, see [llms.txt](https://gyansetu-sql.gitbook.io/sql-programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gyansetu-sql.gitbook.io/sql-programming/sql-select/sql-where/sql-like-operator.md).

# SQL LIKE Operator

### The SQL LIKE Operator

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

There are two wildcards used in conjunction with the LIKE operator:

* % - The percent sign represents zero, one, or multiple characters
* \_ - The underscore represents a single character

&#x20;The percent sign and the underscore can also be used in combinations!

#### LIKE Syntax

```sql
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;
```

> **Tip:** You can also combine any number of conditions using AND or OR operators.

Here are some examples showing different LIKE operators with '%' and '\_' wildcards:<br>

![](https://826093633-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LS8lPNzCGPR5-DLbGXv%2F-LSTGflshH5hVURQmEc6%2F-LSTI3CGmC6R0q4UHZPs%2Fimage.png?alt=media\&token=9efdf466-780f-4a81-a8c5-3a7df1e2f1aa)

**Demo Database**

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

![](https://826093633-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LS8lPNzCGPR5-DLbGXv%2F-LSTGflshH5hVURQmEc6%2F-LSTIqP3VP8MTg5-3UZg%2Fimage.png?alt=media\&token=78c1ab7b-e05e-46ca-b157-3f9eee15ce16)

\
**SQL LIKE Examples**

The following SQL statement selects all customers with a CustomerName starting with "a":

```sql
SELECT * FROM Customers
WHERE CustomerName LIKE 'a%';
```

The following SQL statement selects all customers with a CustomerName ending with "a":

```sql
SELECT * FROM Customers
WHERE CustomerName LIKE '%a'
```

The following SQL statement selects all customers with a CustomerName that have "or" in any position

```sql
SELECT * FROM Customers
WHERE CustomerName LIKE '%or%';
```

The following SQL statement selects all customers with a CustomerName that have "r" in the second position:

```sql
SELECT * FROM Customers
WHERE CustomerName LIKE '_r%';
```

The following SQL statement selects all customers with a CustomerName that starts with "a" and are at least 3 characters in length:

```sql
SELECT * FROM Customers
WHERE CustomerName LIKE 'a_%_%';
```

The following SQL statement selects all customers with a ContactName that starts with "a" and ends with "o":

```sql
SELECT * FROM Customers
WHERE ContactName LIKE 'a%o';
```

The following SQL statement selects all customers with a CustomerName that does NOT start with "a":

```sql
SELECT * FROM Customers
WHERE CustomerName NOT LIKE 'a%';
```

<br>

<br>

\
\ <br>
