1.I have two databases(i.e database_1m and database_current)
2.I have inserted some columns in include_status table(i.e in database_1m).I want to insert the same tables in the database_current.
3.Each database has the time field in database_1m i will get all timings but in the second database i need only the recent time rows so i used mysql query to take the recent updated time rows(i.e select * from include_status where time=(select max(time) from include_status);)
4.Here i dont konw how to use both databases in the same subroutine using perl? code:
sub data
{
$DBH = &connect or die "Cannot connect to the sql server \n";
$DBH->do("USE database_1m;");
$stmt = "INSERT INTO include_status(time,available,closed,used,busy,reserved,down) VALUES(\"$current_time\",\"$include{'D'}\",\"$include{'B'}\",\"$include{'A'}\",\"$include{'C'}\",\"$include{'R'}\",\"$include{'+'}\")";
my $sth = $DBH->prepare( $stmt );
$sth->execute() or print "Could not insert data";
$sth->finish;
$DBH->disconnect();
}
Mysql query:(to insert the recent updated rows)
select * from include_status where time=(select max(time) from include_status);
INSERT INTO include_statuswhich tells me include_status is a table name?