Use Of LIKE and ILIKE

Like statement helps Matches exact string comparison.

Using the Customers table as reference Assuming we want to retrieve Customers who has the letter "O" in their first_name; Syntax

SELECT *
FROM customers
WHERE first_name LIKE "%o%"

Result produces;

customer_id
first_name
last_name
age
country

1

John

Doe

31

USA

2

Robert

Luna

22

USA

4

John

Reinhardt

25

UK

Use Of ILIKE

Allows matching of strings based on comparison with a pattern. Unlike the LIKE function, string matching is case-insensitive.

SELECT *
FROM customers
WHERE first_name ILIKE "%robert%";
customer_id
first_name
last_name
age
country

2

Robert

Luna

22

USA

Last updated