Forum Moderators: open

Message Too Old, No Replies

need to do a search and replace

with mysql

         

ogletree

11:06 pm on Feb 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have a database and I need to do a search and replace to fix some errors. I need to change EL to ELEMENTARY. I have

UPDATE `list_of_schools2` SET School_Name=replace(School_Name,’ EL’,ELEMENTARY’);

Problem is that I have some entries where the first part of a word is EL. I do know that the EL I want to change will always be the last to characters of the field. So what I need is for it to make sure not to replace it unless EL is the last 2 chars of the field.

camble

5:22 am on Feb 3, 2007 (gmt 0)

10+ Year Member



UPDATE `list_of_schools2` SET School_Name=replace(School_Name,’ EL’,ELEMENTARY’) where School_Name like '%EL'

ogletree

1:26 am on Feb 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



got the error

#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 'EL’,ELEMENTARY’) where School_Name like '%EL'' at line 1

ogletree

1:54 am on Feb 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Never mind I got it working there were some strange characters when I copied and pasted.