我有一个表 TABLE_5 ,第二列COLUMN_2的值如下:
first_text_plan (1.1.1.1).txt
second_text_plan (1.1.1.2).txt
one_voice_data_plan (2.1.1.1).txt
one_3g_text_vo (3.1.1.1).txt
and so on.. (more than 500 records)
现在,我想为所有记录更新此列_2,以便在更新COLUMN_2之后应具有以下值:
first_text_plan
second_text_plan
one_voice_data_plan
one_3g_text_vo
如何通过PostgreSQL实现这一目标?
以下查询适用于MySQL数据库:
UPDATE TABLE_5 SET COLUMN_2 = TRIM(SUBSTRING(COLUMN_2, 1, LOCATE('(',COLUMN_2)-1));
答案 0 :(得分:0)
UPDATE table_5 SET column_2 = regexp_replace(column_2, '.\(.*$', '');