Re: [SQL] how to do a find and replace

2005-11-18 Thread Andrew Sullivan
On Thu, Nov 17, 2005 at 02:51:05PM -0800, Dawn Buie wrote: > I'm just confused about how I should write code to update the selected > items to remove the 'v.' > > Would I use substring? An example would be much appreciated. You need a combination of overlay and location. The following will work

Re: [SQL] how to do a find and replace

2005-11-17 Thread A. Kretschmer
am 17.11.2005, um 14:51:05 -0800 mailte Dawn Buie folgendes: > Hello- > > I have a column of data with the wrong prefix for many items. If you have 8.1? If yes: > > The wrong entries are entered ' /0/v.myimage.jpg' > While the correct ones are ' /0/myimage.jpg' > > > I need to remove all the

Re: [SQL] how to do a find and replace

2005-11-17 Thread Hélder M . Vieira
update media_instance set location=replace(location,'v.','') where location like '%/0/v.%' For more complex search/replace operations, 8.1 provides an interesting function, named 'regexp_replace'. It probably goes unnoticed because although there is a small reference in the manual in section

Re: [SQL] how to do a find and replace

2005-11-17 Thread Bricklen Anderson
Dawn Buie wrote: > I used: > > update media_instance set location=replace(location,'v.','') > where location like '%/0/v.%' > > and that did work- > > thank you very much. > > it seems to me that the replace function is the same as translate()- no? > Right, I forgot your WHERE clause. Some mo

Re: [SQL] how to do a find and replace

2005-11-17 Thread Dawn Buie
I used: update media_instance set location=replace(location,'v.','') where location like '%/0/v.%' and that did work- thank you very much. it seems to me that the replace function is the same as translate()- no? On 17-Nov-05, at 3:55 PM, Bricklen Anderson wrote: Dawn Buie wrote: Hello- I'm

Re: [SQL] how to do a find and replace

2005-11-17 Thread Bricklen Anderson
Dawn Buie wrote: > Hello- > I'm using postgres 7.4 > > I have a column of data with the wrong prefix for many items. > > The wrong entries are entered ' /0/v.myimage.jpg' > While the correct ones are ' /0/myimage.jpg' > > > I need to remove all the 'v.' characters from this column. > > > I'm

[SQL] how to do a find and replace

2005-11-17 Thread Dawn Buie
Hello- I have a column of data with the wrong prefix for many items. The wrong entries are entered ' /0/v.myimage.jpg' While the correct ones are ' /0/myimage.jpg' I need to remove all the 'v.' characters from this column. I'm able to do a SELECT * FROM myTable WHERE location = '%/0/v.%'

[SQL] how to do a find and replace

2005-11-17 Thread Dawn Buie
Hello- I'm using postgres 7.4 I have a column of data with the wrong prefix for many items. The wrong entries are entered ' /0/v.myimage.jpg' While the correct ones are ' /0/myimage.jpg' I need to remove all the 'v.' characters from this column. I'm able to do a SELECT * FROM myTable WHERE