dongyan1548 2013-07-17 06:49
浏览 50

MySQL Regexp在哪里价值[重复]

This question already has an answer here:

I am trying to match a numeric value that is purely numbers to another value in my database that is the same numbers but has symbols etc (it's phone numbers).

How can I get MySQL to only match the regexp of the mainNumber column (which has symbols etc in it) to my value (just numbers)?

Below is my code:

$SQL = "SELECT entities.name
        FROM entities_main_numbers
           LEFT JOIN entities ON entities.id = entities_main_numbers.entityId
        WHERE mainNumber = ?
        LIMIT 1";

E.g. +44 (0)800 123 123 to match against 440800123123

</div>
  • 写回答

4条回答 默认 最新

  • dtxf759200 2013-07-17 07:04
    关注

    You can be creative and match the 9 digits from the right after getting rid of the spaces, but if the full number is needed you can place few more recursive calls to REPLACE eliminating the () and +

    mainnumber = RIGHT(REPLACE('+44 (0)800 123 123', ' ', ''), 9);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行