/    Sign up×
Community /Pin to ProfileBookmark

Replace Specific Characters in mysql PHP

Hi all, I am working with a site with an old database having more than 2000 product entries… and most of the products have the article number as ASC-000-000-00

what i want to do is to replace these article numbers with DSC-000-000-00… I dont want to edit/update every entry for that… what I want is just a simple query or 3-4 PHP statements to accomplish,,, any ideas…

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@ZABIauthorMay 17.2011 — ? that's too funny... plz read my question again... i want to replace character(s) in mysql and records are more than 2000 ... so str_replace is useless there
Copy linkTweet thisAlerts:
@jogolMay 17.2011 — either write a php script that does the following:

db query -> for each entry str_replace() -> update db

or export the db data to a txt file and use the search and replace function of an editor (e.g. Notepad++) and import the data into the db again.
Copy linkTweet thisAlerts:
@criterion9May 17.2011 — Maybe utilizing the built in string manipulation functions of the DB rather than some convoluted flat file hack as suggested...

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html
Copy linkTweet thisAlerts:
@jogolMay 17.2011 — something like this?
[CODE]update table_name set field_name = replace(field_name,'find_this','replace_with_that');[/CODE]
Copy linkTweet thisAlerts:
@criterion9May 17.2011 — something like this?
[CODE]update table_name set field_name = replace(field_name,'find_this','replace_with_that');[/CODE][/QUOTE]


That looks about right. I would test on a sample dataset before throwing production data through it just to be safe though. ?
Copy linkTweet thisAlerts:
@ZABIauthorMay 18.2011 — something like this?
[CODE]update table_name set field_name = replace(field_name,'find_this','replace_with_that');[/CODE][/QUOTE]


Thanx man... thats what I wanted ?
×

Success!

Help @ZABI spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...