开发者

Script for reformatting string in all entries

开发者 https://www.devze.com 2023-01-24 07:56 出处:网络
currently, I am using a SQLite database with开发者_开发问答 some addresses and telephone numbers. All phone numbers are stored as text without the international prefix, e.g. 0123 / 4567890. Now, I wou

currently, I am using a SQLite database with开发者_开发问答 some addresses and telephone numbers. All phone numbers are stored as text without the international prefix, e.g. 0123 / 4567890. Now, I would like to store them in the international format with the country prefix, +49 123 4567890 in the example above. As there are several hundreds of datasets, I am searching for a bash script, maybe even a single SQL command, whatever fits best to reformat all those entries at once.

Thanks in advance!


Here's a simple SQLite UPDATE query to convert 0 prefix to +49 country code and remove / and spaces.

UPDATE tablename SET tel = '+49'||replace(replace(substr(tel,2), '/',''), ' ', '') WHERE tel LIKE '0%';
0

精彩评论

暂无评论...
验证码 换一张
取 消