The previous article describes database lookup filtering using some keywords with corresponding SQL statements, but the complexity of the WHERE clause itself increases as the complexity of filtering conditions increases. We can then use regular expressions to make matching lookups.
1. Basic character Matching
Select * fromProductswhereProd_name RegExp' +' Order byProd_name;--match the product name to 1000 of the character items that appearSelect * fromProductswhereProd_name RegExp'.' Order byProd_name;--To match any character, and a statement that matches any character ending with 000
2. Make or Match
Select * from where ' 1000|2000 ' Order by -- Match Product name contains 1000 or 2000 of the product information
3. Match one of several characters
Select * from where [123] Order by --
4. Match Range
Select * from where [1-9] Order by --
5. Match Special characters
Select * from where ' \\. ' Order by -- In regular expressions. To match any character, has a special meaning, we should use \ \ Escape when matching.
Other elements that also need to be escaped:
\\f, \\n, \\r enter; \\t tabulation; \\v longitudinal tabulation
6. Matching multiple instances
Select from where ' \ \ ([0-9] sticks?\\) ' Order by Prod_name; -- \ \ (means match (, [0-9] means match any character?) Indicates a match of 0 or 1 characters
*: Match 0 or more characters
+: Match 1 or more characters
? : matches 0 or 1 characters
^: Beginning of the text
$: End of text
MySQL Learning note (i)--use of regular expressions