Jump to content

how to replace value in whole database.


zohab

Recommended Posts

hi all,

 

if i want to update table with new value i will do as

update table set id='4' where id='3'

this will replace id='3' to id='4'

 

table

id name

1  name1

2  name2

3 name3

 

but if i want to replace it in whole database ,how will i do it.

 

table 1

id name

1  name1

2  name2

3 name3

 

table 2

id name

1  name1

2  name2

3 name3

 

table 3

id name

1  name1

2  name2

3 name3

 

any ideas?

 

Link to comment
Share on other sites

hi thorpe ,

 

I have 100 tables in my database and i want to replace 'xyz' to 'pqr'

 

I am not able to do it for every table.For this i have to write 100 queries.

 

i want to run one small query that will replace 'xyz' to 'pqr' in whole database (includes 100 tables)

 

Link to comment
Share on other sites

hi thorpe ,

 

I have 100 tables in my database and i want to replace 'xyz' to 'pqr'

 

I am not able to do it for every table.For this i have to write 100 queries.

 

i want to run one query that will replace 'xyz' to 'pqr' in whole database (includes 100 tables)

 

 

First create a VIEW by using a UNION between all the 100 tables

Then maken 1 query on that VIEW

 

Usefull info :

http://dev.mysql.com/doc/refman/5.0/en/create-view.html

http://dev.mysql.com/doc/refman/5.0/en/union.html

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.