mysql update with regexp

后端 未结 3 1586
旧巷少年郎
旧巷少年郎 2021-01-11 16:28

I want to remove something from my table 1) 32) 121) 1000)... the format is number + )

相关标签:
3条回答
  • 2021-01-11 16:39

    As an alternative, depending on the size of the table, you could do a workaround with substring function.

    0 讨论(0)
  • 2021-01-11 16:45

    You can't: Mysql doesn't support regex-based replace.

    See this SO question for a work-around.

    0 讨论(0)
  • 2021-01-11 16:54

    Finally, I use some php to solve this problem with a quickly method.

    for ($i=1; $i<=9999; $i++){
     $my_regex = $i.')';
     mysql_query("UPDATE articles SET title = REPLACE(title,'".$i."', '' ) where title like '%".$i."%'");
    }
    
    0 讨论(0)
提交回复
热议问题