【发布时间】:2014-04-23 11:15:55
【问题描述】:
我得到了一个变量列表来循环访问数据库。如何检测变量不在数据库中?我应该使用什么查询?一旦检测到变量不在数据库中,如何打印出错误消息。
我的代码:
$variable = $sql->{'variable'};
foreach my $sql (@Records){
**Below statement will select existed variable, what should I change to make it select not existed variable**
$sqlMySQL = "Select LOT from table where LOT like '%$variable%'";
}
**If not exist**{
print("Not exist")
}
预期结果:
当$variable循环数据库时,如果$variable在数据库中不存在则打印出$variable或者不存在。
感谢观看、cmets 和回答。
【问题讨论】: