Sunday 23rd of November 2008

Replacing text in a table field

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ... Posted on: April 3rd, 2008 by admin

Sometimes it is necessary to replace some of your known data with something else. For example if you have the word Downtown you may want to say CBD instead.

In SQL you can do this using the replace directive.

select name=replace(name, ‘Downtown’, ‘CBD’) from places

This doesent change the table but simply changes the dataset meaning you can use SQL to do basic editing before you display it. It speeds up deployment as you dont have to read the field in ASP/PHP and change it. You do all that hard work in SQL.

    Related posts

Leave a Reply

You must be logged in to post a comment.

Headlines

Feeds