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,753
  • 72
  • 57
  • 129
DGraham
  • 705
  • 2
  • 10
  • 23

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,593
  • 13
  • 50
  • 55
0

Since you asked for an efficient way:

UPDATE tbl
SET    col = translate(col, '"', '')
WHERE  col LIKE '%"%';
Community
  • 1
  • 1
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228