我的数据库中有两个表,它们在不同表的不同列中具有公共值。我想用数据库中所有表的新值替换值
例如:
TBL1:
id gid pid
1 local new
2 remote old
3 local local
4 remote new
TBL2:
id gid pid
1 local new
2 new old
3 local local
4 remote local
我想在数据库标签的所有表中用IP 10.0.0.0
替换“本地”字。
答案 0 :(得分:0)
你可以通过使用php和mysql来实现这一点,如下所示......
<?php
$db = mysql_connect(‘localhost’,’myuser_mydbuser‘,’mypassword‘);
if(!$db) echo "Cannot connect to the database – incorrect details";
mysql_select_db(‘myuser_mydbname’);
$result=mysql_query(‘show tables’);
while($tables = mysql_fetch_array($result)) {
foreach ($tables as $key => $value) {
mysql_query("UPDATE $value set pid = '10.0.0.0' WHERE pid = 'local' ");
}}
echo "The collation of your database has been successfully changed!";
?>