RLike basically use as regular expression in string character, match the string and return result. If we talk about ‘LIKE’ uses as wildcard and ‘%’ substitute for unlimited amount of characters and finding the beginning and end of the character string.
If % use in starting then the result return for example:
If % use in starting then the result return for example:
Select * from Customer Where customerID like ‘%5’
The result will be:
customerID | Name |
5 | John |
15 | smith |
165 | carlos |
Similarly, if % use in ending then the result return for example:
Select * from Customer Where customerID like ‘5%’
customerID | Name |
51 | mular |
52 | anna |
567 | conny |
Now, example of RLIKE:
The wildcards used with RLIKE operator are:
^ indicate BEGINING of the string.
$ indicate END of the string.
| means OR
^ indicate BEGINING of the string.
$ indicate END of the string.
| means OR
Look for Customer names that have substring “John” or substring “Anna”:
SELECT CustomerID, CustomerName FROM Customers WHERE CustomerName RLIKE ‘John|Anna’;
customerID | CustomerName |
10 | smith John |
13 | Anna jos |
0 comments:
Post a Comment