- my $sth =
- $dbh->prepare(
- "Select count(*) from issues where itemnumber=? and branchcode = ?");
- $sth->execute( $itemnumber, $brcd );
- my ($count) = $sth->fetchrow_array;
- $sth->finish;
- return ($count);
+ my $sth = $dbh->prepare(
+ "SELECT SUM(count) FROM (
+ SELECT COUNT(*) AS count FROM issues WHERE itemnumber = ? AND branchcode = ?
+ UNION ALL
+ SELECT COUNT(*) AS count FROM old_issues WHERE itemnumber = ? AND branchcode = ?
+ ) tmp"
+ );
+ $sth->execute( $itemnumber, $brcd, $itemnumber, $brcd );
+ return $sth->fetchrow_array;