Does the MySQL query support regular numbers?

Source: Internet
Author: User
Tags mysql manual
May I ask you how MySQL search can use regular to query a specific number AH?
For example, if I want to query a column with 115 numbers in a field but want to exclude 1115 or 11555555, does MySQL support this query?

Reply content:

May I ask you how MySQL search can use regular to query a specific number AH?
For example, if I want to query a column with 115 numbers in a field but want to exclude 1115 or 11555555, does MySQL support this query?

Compared to the MySQL manual wrote a bit, writing is ugly, no way, did not find \d, (|[ ^0-9X]) also give me an error, alas. mysql5.5.24

mysql> select '115' regexp '^115$|^115[^0-9X]|[^0-9X]115$|[^0-9X]115[^0-9X]' result;+--------+| result |+--------+|      1 |+--------+1 row in set (0.00 sec)mysql> select '1150' regexp '^115$|^115[^0-9X]|[^0-9X]115$|[^0-9X]115[^0-9X]' result;+--------+| result |+--------+|      0 |+--------+1 row in set (0.00 sec)mysql> select '11150' regexp '^115$|^115[^0-9X]|[^0-9X]115$|[^0-9X]115[^0-9X]' result;+--------+| result |+--------+|      0 |+--------+1 row in set (0.00 sec)mysql> select 'a115a' regexp '^115$|^115[^0-9X]|[^0-9X]115$|[^0-9X]115[^0-9X]' result;+--------+| result |+--------+|      1 |+--------+1 row in set (0.00 sec)

Not supported, inefficient and needs to be handled by itself.

Support, but not high efficiency.
SELECT mm,mm REGEXP '. asterisk [^1]115[^5]. Asterisk $ ' from test.a;

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.