Issue with prepared statement
[email protected] (Lethal Possum)
| Newsgroups | perl.dbi.users |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <5478feb9-2e58-4bd8-9a75-6560f686cda3@y21g2000vba.googlegroups.com> |
Hello, I am trying to create a prepared statement for the following query in MySQL: INSERT IGNORE INTO foo (group, value) (SELECT 101, value FROM bar WHERE value LIKE '%something%'); So far my Perl code looks something like this: my $group = 101; my $pattern = '%something%'; my $query = 'INSERT IGNORE INTO foo (group, value) (SELECT ?, value FROM bar WHERE value LIKE ?);'; my $sth = $dbh->prepare($query); $sth->execute($id, $pattern) or die($sth->errstr); It does not insert anything into the table foo even though there are values in table bar that match the pattern. So my question is: what am I doing wrong. I have other, simpler prepared queries in my program that work just fine but this one does not do anything and does not trigger any error as far as I can see. Are ? parameters allowed in a nested SELECT? Are they allowed not in the WHERE clause? Are they allowed with the LIKE operator? Thanks in advance for your help. Tom