SQL
`LIKE`
<div id="rrdiagram1"></div>  
The `LIKE` expression returns `true` if the string matches the supplied pattern. (As expected, the `NOT LIKE` expression returns `false` if `LIKE` returns `true`, and vice versa. An equivalent expression is `NOT (string LIKE pattern)`.)  
If pattern does not contain percent signs or underscores, then the pattern only represents the string itself; in that case `LIKE` acts like the equals operator. An underscore (` _`) in pattern stands for (matches) any single character; a percent sign (` %`) matches any sequence of zero or more characters.  
`LIKE` pattern matching always covers the entire string. Therefore, if it's desired to match a sequence anywhere within a string, the pattern must start and end with a percent sign.  
Some examples:  
```sql
SELECT 'abc' LIKE 'abc'; -- true
SELECT 'abc' LIKE 'a%' ; -- true
SELECT 'abc' LIKE '_b_'; -- true
SELECT 'abc' LIKE 'c';   -- false
SELECT 'abc' LIKE 'c%' ; -- false
SELECT 'abc' LIKE '%c';  -- true
SELECT 'abc' NOT LIKE '%c'; -- false
```  
The keyword `ILIKE` can be used instead of `LIKE` to make the match case-insensitive according to the active locale:  
```sql
SELECT 'abc' ILIKE '%C'; -- true
```  
```sql
SELECT 'abc' NOT ILIKE '%C'; -- false
```  
To search within a string for a character that is a wildcard (` %` or `_`), the pattern must use an `ESCAPE` clause and an escape character to indicate the wildcard should be treated as a literal character instead of a wildcard. See an example below.  
Additionally, the function `like_escape` has the same functionality as a `LIKE` expression with an `ESCAPE` clause, but using function syntax. See the [Text Functions Docs](#docs:sql:functions:char) for details.  
Search for strings with 'a' then a literal percent sign then 'c':  
```sql
SELECT 'a%c' LIKE 'a$%c' ESCAPE '$'; -- true
SELECT 'azc' LIKE 'a$%c' ESCAPE '$'; -- false
```  
Case-insensitive ILIKE with ESCAPE:  
```sql
SELECT 'A%c' ILIKE 'a$%c' ESCAPE '$'; -- true
```  
There are also alternative characters that can be used as keywords in place of `LIKE` expressions. These enhance PostgreSQL compatibility.  
<div class="narrow_table monospace_table"></div>  
| LIKE-style | PostgreSQL-style |
|:---|:---|
| LIKE | ~~ |
| NOT LIKE | !~~ |
| ILIKE | ~~* |
| NOT ILIKE | !~~* |