0

In PostgreSQL a column contains values such as:

"Sample1"
"Sample2"

Is there an efficient way to go through each record removing the " " marks?

This seems like a relatively straightforward operation, but I am baffled.

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
DGraham
  • 685
  • 2
  • 10
  • 22

2 Answers2

0

Try this:

UPDATE TableName
SET ColName = REPLACE(ColName, '"', '');
WHERE ColName SIMILAR TO '%"%'

You can use LIKE operator as well instead of SIMILAR TO.

Raging Bull
  • 18,113
  • 13
  • 47
  • 53
0

Since you asked for an efficient way:

UPDATE tbl
SET    col = translate(col, '"', '')
WHERE  col LIKE '%"%';
Community
  • 1
  • 1
Erwin Brandstetter
  • 539,169
  • 125
  • 977
  • 1,137