Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using regular expressions in MySQL

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The REGEXP function in MySQL can match regular expressions when using SQL, and when using some query conditions, you can use the REGEXP function to match the corresponding characters, which can replace many SQL functions that you are not familiar with or do not understand and are universal, so as to improve the daily work efficiency. It is very easy to use the REGEXP function under MySQL. For metacharacters of regular expressions, please see: the return values of the http://jim123.blog.51cto.com/4763600/1850919 quotient REGEXP function are Boolean values 0 and 1, that is, matching is 1, not 0, for example:

Mysql > SELECT'Monty' REGEXP'^ ostentatious Mushroom + | 'montyment.' REGEXP'^ o' | +-- + | 0 | +-- + 1 row in set (0.00 sec) mysql > SELECT 'Monty' REGEXP'^ Mechatronics Mushroom + | 'montysomething' REGEXP'^ M' | +-+ | 1 | +-+ 1 row in set (0.00 sec)

Of course, the REGEXP function can also be simplified to RLIKE, all the same.

Mysql > SELECT'Monty' RLIKE'^ masking; +-+ | 'Montmortal' RLIKE'^ M' | +-+ | 1 | +-+ 1 row in set (0.00 sec)

However, it is important to note that in MySQL, the REGEXP function can only be used for string type matching, not as a numeric value.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report