Coldfusion update query

Railo4 / Mysql 5

In my database I have a field named Address.

Some of these addresses have the string  "205" in them such as:
My Street 205
Another Street 205
etc...

How would you code up  a CF update query to remove the 205?

Any help appreciated!
Bang-O-MaticAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gdemariaCommented:
update address
  set street = replace(street,'205','')

make a copy of your table first and be sure not to delete any occurrences of 205 that should be part of the address :)

you can test it by using this in a select first...

select replace(street,'205','')
from addresses
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bang-O-MaticAuthor Commented:
Perfect solution, Thanks!
0
_agx_Commented:
Assuming the base values shouldn't have ANY leading/trailing spaces, you might also want to trim the values.  Otherwise, you'll end up with:

|My Street(space)|

.. rather than

|My Street|

Just keep in mind you're applying it to the whole table .. so as before - always backup first :)
0
Bang-O-MaticAuthor Commented:
Thanks _agx_ !
0
_agx_Commented:
Welcome :)

BTW, I'm sure you realized this by now, but  replace(street,'205','') will also replace partial matches like "3205 Street" and "My Street 92057", etc....   Unfortunately I don't think there's anything so elegant way as a regex replace built into mySQL.  So you'd probably need to resort to a series of CASE statements if you want to replace the full value only ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.