【发布时间】:2018-06-24 09:32:38
【问题描述】:
我想将从我的数据库中获取的值存储到哈希中。然后,我想比较一下它们是否具有相同的material。如果他们有相同的material,我想比较txt。如果txt 不同,我想使用storedisp。如果文字相同,我想用coursemat:
my $stmt1 = qq(select txt, price, material from coursemat);
my $sth1 = $pagev->runQ($stmt1); #run query in house function
my $stmt2 = qq(select material from storedisp);
my $sth2 = $pagev->runQ($stmt2);
while(my ($txt, $price, $material) = $sth->fetchrow_array) {
%cmhash = (
$material => {
txt => $txt,
price => $price,
},
);
}
while(my $txt = $sth->fetchrow) {
%sdhash = (
$material => {
txt => $txt,
},
);
}
【问题讨论】:
-
您有问题吗?有什么问题? (提示:请参阅 minimal reproducible example 和 edit 你的问题以包括一个)
标签: algorithm perl mariadb hashtable