The PostgreSQL ILIKE operator is used query data using pattern matching techniques. Its result include strings that are case-insensitive and follow the mentioned pattern.
It is important to know that PostgreSQL provides with 2 special wildcard characters for the purpose of patterns matching as below:
- Percent ( %) for matching any sequence of characters.
- Underscore ( _) for matching any single character.
Syntax: string ILIKE pattern;
Now, let’s look into a few examples.
Here we will make a query to find the customer in the “customer” table by looking at the “first_name” column to see if there is any value that begins with “ke” using the ILIKE operator in our sample database.
SELECT first_name, last_name FROM customer WHERE first_name ILIKE 'Ke%';
Notice few things in the above example, the WHERE clause contains a special expression: the first_name, the LIKE operator, and a string that contains a percent (%) character, which is referred to as a pattern.
Here we will query for customers whose first name begins with any single character, is followed by the literal string “aR”, and ends with any number of characters using the ILIKE operator in our sample database.
SELECT first_name, last_name FROM customer WHERE first_name ILIKE '_aR%';
- PostgreSQL - NOT IN operator
- PostgreSQL - IN operator
- PostgreSQL - NOT LIKE operator
- PostgreSQL - IS NULL operator
- PostgreSQL - LIKE operator
- PostgreSQL - NOT BETWEEN operator
- PostgreSQL - BETWEEN operator
- PostgreSQL - UNION operator
- PostgreSQL - INTERSECT Operator
- PostgreSQL - EXCEPT Operator
- PostgreSQL - ANY Operator
- PostgreSQL - SOME Operator
- PostgreSQL - ALL Operator
- PostgreSQL - EXISTS Operator
- PostgreSQL - ORDER BY clause
- PostgreSQL - INNER JOIN
- PostgreSQL - Create Database
- PostgreSQL - COALESCE
- PostgreSQL - CASE Statement
- PostgreSQL - IF Statement
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.