You can always cheat. Use information_schema or just show databases and show tables and loop through it. Just using information_schema is perfect though i think then you can know or query on column type and save some work.

Sent from my iPhone

On Jun 15, 2009, at 1:10 AM, Peter Ford <> wrote:

Chris Payne wrote:
Hi everyone,

I am in the middle of creating an editor where you can search and
replace on an individual column in a single table then I came across
something I need to be able to do but not sure how.

Is it posible (And if so please how :-) to search an entire database
and all tables within a database and do a find/replace on keywords
without having to specify each table/column within that table?

The people I am working for have made some big changes and one of them
is changing the names of one of their products, but this product name
appears EVERYWHERE in many tables and in lots of different column
names, and it would save so much time if I could do a single query
that would just search EVERYTHING within the database.

Thanks for any advice you can give me.


Chris Payne

This is not really a PHP question, is it? More like a question for the support
group that corresponds to your database software...

However, in my experience databases don't allow a cross-table update in a single
query - you won't be able to do it in one query.

You will either have to
1. work out which columns and tables contain the name
2. script a query to make the changes for each separately
3. test it on a backup version of the database
4. fix the bugs
5 run the script on the live database.

OR (possibly)

1. block access to the database (to prevent any changes while you are processing)
2. dump the whole DB to an SQL script
3. do a search and replace on the text of the SQL script
4. Drop the existing data and reload the database from your SQL dump
5. enable access again so that the users can find the (inevitable) mistakes.

These are both pretty time-consuming - sorry!

Then make a business case for the project of normalising the database, at least
with respect to the product names...

Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to