Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change a portion of a field

Status
Not open for further replies.

szaunbr

Technical User
Jul 5, 2006
50
US
I am new to the postgresql "game". I am trying to clean up some data in my database, mainly addresses. What I would like to do is change every instance of 'First' to '1st' in the address field.

Ex: '325 West First St' to
'325 West 1st St'

Is it possible to update just a portion of a field??

Any guidance would be greatly appreciated.
 
Hi

[tt]replace()[/tt] ?
Code:
[blue]db=#[/blue] [b]select[/b] address [b]from[/b] szaunbr;
      address
-------------------
 325 West First St
(1 row)

[blue]db=#[/blue] [highlight #eee][b]update[/b] szaunbr [b]set[/b] address=replace(address,[i]'First'[/i],[i]'1st'[/i]);[/highlight]
UPDATE 1

[blue]db=#[/blue] [b]select[/b] address [b]from[/b] szaunbr;
     address
-----------------
 325 West 1st St
(1 row)

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top