LIKE
SELECT with a LIKE operator
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_unitFROM productsWHERE product_name LIKE '%C%'Run in terminal
This query should return 17 rows
SELECT with a LIKE operator using % and _
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_unitFROM productsWHERE product_name LIKE '_e%'Run in terminal
This query should return 5 rows
SELECT with a NOT LIKE operator
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_unitFROM productsWHERE product_name NOT LIKE 'C%'Run in terminal
This query should return 68 rows
SELECT with an ILIKE operator
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_unitFROM productsWHERE product_name ILIKE '%C%'Run in terminal
This query should return 37 rows