View Single Post

  #2 (permalink)  
Old 11-24-2005
Giuseppe Maxia
 
Posts: n/a
Default Re: Replace string query - double trouble!

Gary@garywhittle.co.uk wrote:
> UPDATE `tableName` SET `fieldName` =
> REPLACE(fieldName,"stringOne","stringTwo")
>
> I use the above code to strip strings from my table, and most of the time
> this works well. However, I have several fields with double quotes within,
> and I would like to remove all double quotes.
>
> Doing this does not work, and generates an error:
>
> UPDATE `tableName` SET `fieldName` = REPLACE(fieldName,""","")
>
> Can anyone point me in the right direction?
>
> Regards,
>
> Gary.
>
>


You need one more double quote to escape it:
UPDATE `tableName` SET `fieldName` = REPLACE(fieldName,"""","")

or you can use single quotes to quote a double quote:
UPDATE `tableName` SET `fieldName` = REPLACE(fieldName,'"',"")

ciao
gmax

--
_ _ _ _
(_|| | |(_|><
_|
http://gmax.oltrelinux.com
Reply With Quote