# The "like" operator

The like operator allows you to check if a value matches a pattern. It can be used with the operator not to check if a value does not match the pattern specified. The expression is structured as follows:

```
value like pattern
```

You can use the following wildcards in the pattern:

| Symbol | Description | Example |
| --- | --- | --- |
| % | Matches zero or more characters. | Pattern: "bl%"<br><br><ul> <li>Matches: <span>"black"</span>, <span>"blue"</span></li> <li>Does not match: <span>"able"</span></li> </ul> |
| \_ | Matches a single character. | Pattern: "h\_t"<br><br><ul> <li>Matches: <span>"hit"</span>, <span>"hat"</span></li> <li>Does not match: <span>"heat"</span></li> </ul> |
| [] | Matches any single character within the brackets. | Pattern: "b[ae]t"<br><br><ul> <li>Matches: <span>"bat"</span>, <span>"bet"</span></li> <li>Does not match: <span>"beat"</span></li> </ul> |
| [start-end] | Matches any single character within the specified range. | Pattern: "[b-d]at"<br><br><ul> <li>Matches: <span>"bat"</span>, <span>"cat"</span>,                  <span>"dat"</span></li> <li>Does not match: <span>"data"</span></li> </ul> |
| [^characters] | Matches any character not in the brackets. | Pattern: "h[^oa]t"<br><br><ul> <li>Matches: <span>"hit"</span>, <span>"hut"</span></li> <li>Does not match: <span>"hot"</span>, <span>"hat"</span></li> </ul> |

## Examples

| Clause | Result |
| --- | --- |
| ```<br>WHERE name LIKE "a%"<br>``` | Returns any element where the value of name starts with<br>a. |
| ```<br>WHERE name LIKE "%a"<br>``` | Returns any element where the value of name ends with<br>a. |
| ```<br>WHERE name LIKE "%bir%"<br>``` | Returns any element where the value of name contains<br>bir. |
| ```<br>WHERE name LIKE "_r%"<br>``` | Returns any element where the second character of the value of<br>nameis r. |
| ```<br>WHERE name LIKE "a__%"<br>``` | Returns any element where value of name starts with<br>a, followed by at least two characters. |
| ```<br>WHERE name LIKE "a%o"<br>``` | Returns any element where value of name starts with<br>a and ends with o. |
| ```<br>WHERE name NOT LIKE "%[A-Z]"<br>``` | Returns any element where value of name does not end with a<br>capital letter. |
| ```<br>WHERE name NOT LIKE "%[^0-9]%"<br>``` | Returns any element where value of name only contains<br>numbers. |