http://www.perlmonks.org?node_id=243501

mooseboy has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

Having decided I need to learn something about Perl's database capabilities, I was just re-reading chapter 13 of Simon Cozens' Beginning Perl (the only book I have that touches on the subject) and have gotten most of the code examples to work, but there's one script that keeps giving me a MySQL error that I just can't figure out. Here it is:

#!/usr/bin/perl use warnings; use strict; use DBI; my ($dbh, $rows); $dbh = DBI->connect('dbi:mysql:test', 'root', '') || die "Error opening database: $DBI::errstr\n"; $rows = $dbh->do("UPDATE checkin SET destination = qq/SELECT destination FROM checkin WHERE firstname='Henry' AND lastname='Rollins'/ WHERE firstname='Bill' AND lastname='Gates' ") || die "Couldn't insert record : $DBI::errstr"; print "$rows row(s) added to checkin"; $dbh->disconnect || die "Failed to disconnect\n";

The error I get is as follows:

DBD::mysql::db do failed: You have an error in your SQL syntax near 'S +ELECT destination FROM checkin WHERE firstname='Henry' AND last' at line 3 at ./broken line 1 +1. Couldn't insert record : You have an error in your SQL syntax near 'SE +LECT destination FROM checkin WHERE firstname='Henry' AND last' at line 3 at ./broken line 1 +1.

I've spent ages ploughing through the MySQL docs, but as these are my first wobbly steps in relational databases, I'd be grateful for any assistance.

TIA, mooseboy