Re: UPDATE query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I found a way to do this Bastien:

UPDATE `database`.`table` SET `toll_free` = CONCAT( '1-', `toll_free` ) WHERE `toll_free` LIKE '866-%'

Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

-----Original Message----- From: Bastien Koert
Sent: Tuesday, March 08, 2011 11:20 AM
To: Ron Piggott
Cc: php-db@xxxxxxxxxxxxx
Subject: Re:  UPDATE query

On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
<ron.piggott@xxxxxxxxxxxxxxxxxx> wrote:

I am wondering if there is a way to do an UPDATE query where only some of the text changes.

The column I need to modify is named “toll_free”
What I need to search for is: 800-
I need it to replace it with is 1-800-
- BUT I don’t want to change instances of 1-800-
- I need to leave the rest of the toll free phone number in tact.

Ron


The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info


Ron,

I would strongly suggest that you be consistent in the data. Pick one
version (1-800 or 800-) and stick with it. Its a simple matter to do a
one time replace on that field to make them all consistent and from
there on your programming logic for the update you want to run is then
made much simpler.

You can do an update with a LIKE but it may update more than what you want to

update table set toll_free = '$some_value' where toll_free like '%800-###-####'

--

Bastien

Cat, the other other white meat

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux