mySql - find and replace.
mySql - find and replace.
am 21.08.2007 13:52:45 von Richard
Hi there.
Am a total newbie to sql language.
Does mySql have a find and replace function
or can a command be written to perform such
a task.
In the table I have a column named MEDAL_NAME
I wish to change all entries in that colum that
contain the words "War Plaque" to "Memorial Plaque"
Any pointers gratefully received
Re: mySql - find and replace.
am 21.08.2007 14:00:32 von Richard
I have tried:
UPDATE [LISTINGS] SET [MEDAL_NAME] = replace( [MEDAL_NAME], '[War Plaque]',
'[Memorial Plaque]' )
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'[LISTINGS] set [MEDAL_NAME] = replace([MEDAL_NAME],'[War
Plaque]','[Memorial Pla' at line 1
????????
"Richard" wrote in message
news:hmAyi.23818$ie3.23309@newsfe3-gui.ntli.net...
> Hi there.
> Am a total newbie to sql language.
>
> Does mySql have a find and replace function
> or can a command be written to perform such
> a task.
>
> In the table I have a column named MEDAL_NAME
>
> I wish to change all entries in that colum that
> contain the words "War Plaque" to "Memorial Plaque"
>
> Any pointers gratefully received
>
>
Re: mySql - find and replace.
am 21.08.2007 14:20:45 von luiheidsgoeroe
On Tue, 21 Aug 2007 14:00:32 +0200, Richard wrote=
:
>
> I have tried:
> UPDATE [LISTINGS] SET [MEDAL_NAME] =3D replace( [MEDAL_NAME], '[War =
> Plaque]',
> '[Memorial Plaque]' )
>
> MySQL said:
>
> #1064 - You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use n=
ear
> '[LISTINGS] set [MEDAL_NAME] =3D replace([MEDAL_NAME],'[War
> Plaque]','[Memorial Pla' at line 1
>
> ????????
I assume the blockquotes aren't there...
UPDATE `LISTINGS` SET `MEDAL_NAME` =3D REPLACE(`MEDAL_NAME`, 'War =
Plaque','Memorial Plaque')
(Are you sure the tablename & fielname are all in capitals? Default woul=
d =
be lowercase AFAIK).
-- =
Rik Wasmus
Re: mySql - find and replace.
am 21.08.2007 14:21:16 von geoff
"Richard" wrote in message
news:hmAyi.23818$ie3.23309@newsfe3-gui.ntli.net...
> Hi there.
> Am a total newbie to sql language.
>
> Does mySql have a find and replace function
> or can a command be written to perform such
> a task.
>
> In the table I have a column named MEDAL_NAME
>
> I wish to change all entries in that colum that
> contain the words "War Plaque" to "Memorial Plaque"
>
> Any pointers gratefully received
>
>
http://www.w3schools.com/sql/sql_update.asp
UPDATE table_name
SET column_name = new_value
WHERE column_name = some_valuesomething like the above will dothat site is
quite handy when starting out i found
Re: mySql - find and replace.
am 21.08.2007 14:27:54 von Richard
OK Corrected the syntax - see below
"Rik" wrote in message
news:op.txeskv0rqnv3q9@metallium...
On Tue, 21 Aug 2007 14:00:32 +0200, Richard wrote:
>
> I have tried:
> UPDATE [LISTINGS] SET [MEDAL_NAME] = replace( [MEDAL_NAME], '[War
> Plaque]',
> '[Memorial Plaque]' )
>
> MySQL said:
>
> #1064 - You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use near
> '[LISTINGS] set [MEDAL_NAME] = replace([MEDAL_NAME],'[War
> Plaque]','[Memorial Pla' at line 1
>
> ????????
I assume the blockquotes aren't there...
UPDATE `LISTINGS` SET `MEDAL_NAME` = REPLACE(`MEDAL_NAME`, 'War
Plaque','Memorial Plaque')
(Are you sure the tablename & fielname are all in capitals? Default would
be lowercase AFAIK).
--
Rik Wasmus
Should Be:
UPDATE `LISTINGS` SET `MEDAL_NAME` = REPLACE(`MEDAL_NAME`, "War
Plaque","Memorial Plaque")
Changed to double commas and it carried out the order!! Thanks all