Lesson 3.6
SQL LIKE: Pattern Matching
Pattern matching helps when text values are useful but not perfectly exact.
Exact matches are useful, but text data often needs a softer search. LIKE compares a text value to a pattern instead of one exact value.
The most common wildcard is %, which means any number of characters. So '%Soil%' matches text with Soil anywhere inside it.
Pattern
select column_one, column_two
from table_name
where text_column like '%some text%'Schema · Garden ShopTable · products9 columns · 24 rows
Table · products
9 columns · 24 rowsOne row per product, with price, cost, and inventory levels.
product_id intproduct_name textcategory_id intsupplier_id intprice decimalcost decimalquantity_on_hand intreorder_level intdiscontinued bool
Your task
Show the product name and price for every product whose name contains Soil.
SQL Workbench
⌘↵ to run·
Expected answer
- Columns: product_name, price.
- Rows: 2 products.
- Both product names should contain Soil.