Re: UPDATE query
| From: | Omega -1911 | Date: | Sat, 19 Mar 2011 23:10:48 +0000 |
| Subject: | Re: UPDATE query | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-47729@lists.php.net to get a copy of this message | ||
On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
<ron.piggott@actsministries.org> 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.
>
Another example::
-------------------------------------
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this
string’, ‘replace found string with this string’);
update client_table set company_name = replace(company_name, ‘Old
Company’, ‘New Company’)
The above statement will replace all instances of ‘Old Company’ to
‘New Company’ in the field of company_name of client_table table.