UPDATE query
am 08.03.2011 17:16:14 von ron.piggott
------=_NextPart_000_00B1_01CBDD82.3CE52BD0
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I am wondering if there is a way to do an UPDATE query where only some =
of the text changes. =20
The column I need to modify is named â=9Ctoll_freeâ=9D
What I need to search for is: 800-
I need it to replace it with is 1-800-
- BUT I donâ=99t want to change instances of 1-800-=20
- I need to leave the rest of the toll free phone number in tact.
Ron
The Verse of the Day
â=9CEncouragement from Godâ=99s Wordâ=9D
http://www.TheVerseOfTheDay.info =20
------=_NextPart_000_00B1_01CBDD82.3CE52BD0--
Re: UPDATE query
am 08.03.2011 17:20:24 von Phpster
On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
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 =93toll_free=94
> What I need to search for is: 800-
> I need it to replace it with is 1-800-
> - BUT I don=92t 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
> =93Encouragement from God=92s Word=94
> 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 =3D '$some_value' where toll_free like '%800-###=
-####'
--=20
Bastien
Cat, the other other white meat
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: UPDATE query
am 08.03.2011 17:22:31 von ron.piggott
I was wondering this Bastien. Ron
The Verse of the Day
Encouragement from Gods Word
http://www.TheVerseOfTheDay.info
-----Original Message-----
From: Bastien Koert
Sent: Tuesday, March 08, 2011 11:20 AM
To: Ron Piggott
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] UPDATE query
On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
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 dont 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 Gods 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
Re: UPDATE query
am 09.03.2011 00:16:47 von ron.piggott
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 Gods Word
http://www.TheVerseOfTheDay.info
-----Original Message-----
From: Bastien Koert
Sent: Tuesday, March 08, 2011 11:20 AM
To: Ron Piggott
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] UPDATE query
On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
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 dont 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 Gods 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
Re: UPDATE query
am 18.03.2011 22:24:18 von Jim Giner
to be correct you really should NOT append the 1 to any phone number. That
"1" is not actually part of the number, it is merely a tool used by
land-line phones that triggers the "long distance" feature. If you use a
cell phone, you already know that you don't use a '1' when making a
long-distance call.
When one looks up a number you should provide them with the 10 digit number
(in the U.S.) and let THEM figure out how to dial it. Suppose they are on
an office phone system like the old Centrex ones where to get long distance,
you had to get an outside line which meant dialing a 9 first. Are you going
to add 9's to your numbers to?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: UPDATE query
am 20.03.2011 00:10:48 von Omega -1911
On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
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 =93toll_free=94
> What I need to search for is: 800-
> I need it to replace it with is 1-800-
> - BUT I don=92t 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 =3D replace(FIELD_NAME, =91find this
string=92, =91replace found string with this string=92);
update client_table set company_name =3D replace(company_name, =91Old
Company=92, =91New Company=92)
The above statement will replace all instances of =91Old Company=92 to
=91New Company=92 in the field of company_name of client_table table.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php