community/learn/content/01-SQL-Basics/02-fundamentals/09-like.md
In this exercise we will query the products table and find all the products whose names have the letter C in them.
SELECT product_id,
product_name,
quantity_per_unit
FROM products
WHERE product_name LIKE '%C%'
This query should return 17 rows
In this exercise we will query the products table and find all the products whose names have a single character before the letter E appears in them.
SELECT product_id,
product_name,
quantity_per_unit
FROM products
WHERE product_name LIKE '_e%'
This query should return 5 rows
In this exercise we will query the products table and find all the products whose names do not start with the letter C.
SELECT product_id,
product_name,
quantity_per_unit
FROM products
WHERE product_name NOT LIKE 'C%'
This query should return 68 rows
In this exercise we will query the products table using the ILIKE operator (which acts like the LIKE operator) to find the products that have the letter C in them. In addition, the ILIKE operator matches value case-insensitively.
SELECT product_id,
product_name,
quantity_per_unit
FROM products
WHERE product_name ILIKE '%C%'
This query should return 37 rows