Home >Database >Mysql Tutorial >How to remove brackets and everything in brackets from a string in MySQL

How to remove brackets and everything in brackets from a string in MySQL

王林
王林forward
2023-06-02 21:27:322624browse

    Remove the brackets in the string and everything inside the brackets

    How to remove brackets and everything in brackets from a string in MySQL

    update 表 set 列名 =  REPLACE(列名,SUBSTRING(列名 , LOCATE( '(',列名) , LOCATE(')',列名)) ,被替换的字符)

    How to remove brackets and everything in brackets from a string in MySQL

    Function used

    • replace(column name, replaced string, replaced string): Replace part of the content in the string

    • substring (column name, starting position, ending position): intercept a part of the string

    • locate (searched string, column name): Find the position of a certain character in the string

    MySQL field and remove the brackets

    eg:

    select * 
    from (select *,substring_index(substring_index(remarks,"[",1),']',-1) as carCard from test )  as t
    where carCard LIKE '%C999%'

    The above is the detailed content of How to remove brackets and everything in brackets from a string in MySQL. For more information, please follow other related articles on the PHP Chinese website!

    Statement:
    This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete
    Previous article:How Docker creates MySQLNext article:How Docker creates MySQL