Postgresql query to update fields using a regular expression

前端 未结 2 2080
一整个雨季
一整个雨季 2021-02-19 17:47

I have the following data in my \"Street_Address_1\" column:

123 Main Street

Using Postgresql, how would I write a query to update t

2条回答
  •  死守一世寂寞
    2021-02-19 18:17

    Something like...:

    UPDATE table
    SET Street_Name = substring(Street_Address_1 FROM '^[0-9]+ ([a-zAZ]+) ')
    

    See relevant section from PGSQL 8.3.7 docs, the substring form is detailed shortly after the start of the section.

提交回复
热议问题