SQL WHERE LIKE Statement

  • WHERE LIKE determines if a character string matches a pattern.
  • Use WHERE LIKE when only a fragment of a text value is known.
  • WHERE LIKE supports two wildcard match options: % and _.
The definitive guide
for data professionals


Order today!
 See 2 min video



The SQL WHERE LIKE syntax


The general syntax is:
SELECT column-names
  FROM table-name
 WHERE column-name LIKE value 

Optional Wildcard characters allowed in 'value' are % (percent) and _ (underscore).
  A % matches any string with zero or more characters.
  An _ matches any single character.




SQL WHERE LIKE Examples




Problem: List all products with names that start with 'Ca'
SELECT Id, ProductName, UnitPrice, Package
  FROM Product
 WHERE ProductName LIKE 'Ca%'


Results: 2 records.



Id ProductName UnitPrice Package
18 Carnarvon Tigers 62.50 16 kg pkg.
60 Camembert Pierrot 34.00 15-300 g rounds





Problem: List all products that start with 'Cha' or 'Chan' and have one more character.
SELECT Id, ProductName, UnitPrice, Package
  FROM Product
 WHERE ProductName LIKE 'Cha_' OR ProductName LIKE 'Chan_'


Results: 2 records.



Id ProductName UnitPrice Package
1 Chai 18.00 10 boxes x 20 bags
2 Chang 19.00 24 - 12 oz bottles