使用纯 sql 语句,怎么把电话号中 0413 替换成 024
LIKE
这个查一下 pg 的语法就行了。 update table_name set field_name = regexp_replace(field_name, '^0413', '024');
#2 楼 @pongyo ok,找到了,谢谢
http://www.postgresql.org/docs/9.2/static/functions-string.html
语法:replace(string text, from text, to text) #Replace all occurrences in string of substring from with substring to 例子:replace('abcdefabcdef', 'cd', 'XX') abXXefabXXef
update companies set contact_phone = regexp_replace(companies.contact_phone, '^0413', '024') where contact_phone like '0413%' or mobile_phone like '0413%'