首页 > 解决方案 > 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;

感谢您的答复

标签: sqlperlmariadbdbi

解决方案


使用单个连接。使用 db.table 语法引用表。


推荐阅读