I would like to insert values into two separate MySQL tables using DBI. I tried to combine two working INSERT queries into one by inserting a ; between them:
$dbh->do(q{
INSERT INTO `testA`(test) values('testvalue111');
INSERT INTO `testB`(test) values('testvalue222');
});
But I always get an error:
Syntactic error in “INSERT INTO `testB`(test) values(‘testvalue222 …”
If I separate the queries into two separate do calls, it works. But the combined query works fine in phpMyAdmin. Why does it fail in Perl?
You need to set an option in the
connectcall to enable this. From the docs:It is disabled by default, and should probably remain unset – that’s a large avenue for SQL injection (which you should be reading about especially if you’re not using binds).