Using the LIKE operator in MySQL is to tell MySQL that the following search patterns are matched using wildcards.
percent wildcard
The percent sign represents any number of occurrences of any character. For example, the following sql can find all p_name products starting with apple in produces:
SELECT p_id FROM products WHERE p_name LIKE 'apple%'
- Note that trailing spaces will lead to unsuccessful matching. Solution 1. Add % at the end; Solution 2. Use a function to remove trailing spaces (recommended).
underscore wildcard
The underscore wildcard can represent any character appearing once
SELECT p_id FROM products WHERE p_name LIKE '_o_'
📢 Wildcard search is inefficient and should be used with caution.
Reference: Forta B. MySQL crash course[M]. Pearson Education India, 2006.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。