Search and Replace

From: "Randy D(dot) McCracken" <rdm(at)srs(dot)fs(dot)usda(dot)gov>
To: pgsql-sql(at)postgresql(dot)org
Subject: Search and Replace
Date: 2003-01-08 14:02:47
Message-ID: Pine.LNX.4.44.0301080901150.28293-100000@www.srs.fs.usda.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

I apologize for having to resort to sending what is most likely a simple
tech support question regarding PostgreSQL to this list but I have not
been able to find the answer in the documentation.

I am responsible for managing a database containing over 6,000 records of
US Forest Service Research publications
(http://www.srs.fs.usda.gov/pubs/search.jsp) and I need to do a simple
search and replace in one of the columns. In these records we have a
field for URLs of the location the research publications and I need to
change the base URL from www.srs.fs.fed.us to www.srs.fs.usda.gov. It
seems like this "search and replace" would be a simple thing to do with an
UPDATE command but I am having great difficulty making this work.

The table definition I am trying to update is: url. At first I thought
about using a simple UPDATE command like this:

UPDATE publications SET url = 'www.srs.fs.usda.gov' WHERE url =
'www.srs.fs.fed.us';

Of course that would work fine but "www.srs.fs.fed.us" is only part of a
complete URL such as: http://www.srs.fs.fed.us/pubs/rp/rp_se263.pdf. My
problem (among other things!) is that I don't know how to pass along
wildcards so that I do not change the other parts of the complete URL. I
have tried substituting "like" for "=" and trying to use the wildcard of
"%" but to no avail. I am really just guessing here.

Any help would be greatly appreciated!

Best,

--rdm

=======================================
Randy D. McCracken (0>
Web Guy //\
Communications Group V_/_

USDA/FS - Southern Research Station

E-Mail: rdm(at)srs(dot)fs(dot)usda(dot)gov
Voice: (828) 259-0518
Fax: (828) 257-4840
Web: http://www.srs.fs.fed.us/
=======================================

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2003-01-08 14:56:23 Re: Search and Replace
Previous Message Achilleus Mantzios 2003-01-08 13:59:53 Re: SQL list table names

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Rowell 2003-01-08 14:49:00 to_date() confusion
Previous Message Achilleus Mantzios 2003-01-08 13:59:53 Re: SQL list table names