sql - perl - 从两个数据库更新
问题描述
我在 mariadb 中有两个数据库,我想更新两个数据库,
#Connect to the database1.
my $db1 = DBI->connect("DBI:mysql:database=db1;host=ip",
"login", 'paswword',
{'RaiseError' => 1});
#Connect to the database2.
my $db2 = DBI->connect("DBI:mysql:database=db2;host=ip",
"login", 'password',
{'RaiseError' => 1});
此查询不起作用
my $query3 = $db1->prepare("
UPDATE worldmap.worldmap_table t1
SET t1.severity = 1000
WHERE t1.host IN
(SELECT h.name
FROM host_inventory as i, hosts as h WHERE i.hostid=h.hostid and h.available=1)");
$query3->execute;
感谢您的答复
解决方案
使用单个连接。使用 db.table 语法引用表。
推荐阅读
- amazon-web-services - 如何使用数据存储在 dynamodb 中处理用户访问授权
- dart - 如何将列表转换为字符串并保存它的引号?
- azure-data-factory - 在数据流中接收后创建的额外 Blob
- java - 位图未更新/显示旧值
- java - 通用 Guice 模块
- data-warehouse - 如何在 Synapse 中定义数据仓库单元?
- reactjs - 如何在 npm RunKit 上显示渲染的 React 组件?
- reactjs - 将更多图像从 react-native 应用程序上传到 firebase
- php - 使用 Supervisord - Apache 超时
- scala - SBT 总是在 Docker、docker-compose 上下载包/scala 库