SQL: Wildcard Search With The LIKE Operator
Equality searches are great and efficient when you want exact matches or range of values. However, there will be times when you need to search a text field for not so perfect matches, perhaps a partial match is needed. Certain scenarios requires to search for patterns, such as an email address. That's when the LIKE operator is useful in SQL. The only caveat is that LIKE operators can only work with text fields. Examples: 1. A word/text with a % at the end, searches for all the records that begins with the letters before the percent sign SELECT ProductName,UnitPrice FROM Products WHERE ProductName LIKE 'Chef%' The query above returns all the records in the Products table that begins with the word "Chef" 2. A word with % sign on both ends, means that the result will be any records that contains the enclosed word/text within the % sign SELECT ProductName,UnitPrice FROM Products WHERE ProductName LIKE '%Hot%' The query above searches for any records t...