Nidhi Gupta
3 min readSep 14, 2021

--

“LIKE” vs “ILIKE” operator in PostgreSQL

In this article, we will walk through the “LIKE” and “ILIKE” operators used in PostgreSQL.

PostgreSQL is a case-sensitive language in order to make it a case-insensitive language during pattern matching we make use of the ILIKE operator.

ILIKE operator works the same way as a LIKE operator but makes the language case-insensitive. Both the operators are used for pattern matching in PostgreSQL.

Pattern matching operators

1) LIKE (~~)

Syntax: WHERE value LIKE ‘xyz%’

2) NOT LIKE (!~~)

Syntax: WHERE value NOT LIKE ‘xyz%’

3) ILIKE (~~*)

Syntax: WHERE value ILIKE ‘xyz%’

4) NOT ILIKE (!~~*)

Syntax: WHERE value NOT ILIKE ‘xyz%’

To understand pattern matching operators let's consider problem statements.

Consider a table called contacts having columns domainname, metatitle, metadescription, email, and emaildescription.

SELECT * FROM CONTACTS;

--

--

Nidhi Gupta

Azure Data Engineer 👨‍💻.Heading towards cloud technologies expertise✌️.