how to find and replace a word in a mysql column?

前端 未结 2 966
青春惊慌失措
青春惊慌失措 2021-02-04 02:35

I have a column containing list of streets. I need to replace \'street\' with \'St\'. The replacement can be made in the current column or in a new column with the address in th

相关标签:
2条回答
  • 2021-02-04 03:01

    Run a query like this to update in the same column:

    UPDATE table 
       SET column = REPLACE(column, 'Street', 'St');
    
    0 讨论(0)
  • 2021-02-04 03:11

    So, if i understand correctly, you want to modify the data on the database based on wether or not you're using the word street. I think this is the call u need.

    update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');
    

    I think this is the method you need to use, so your ending code will look something like

    update myTable set address = replace(address,'street','St');
    

    Is this what you meant?

    0 讨论(0)
提交回复
热议问题