title: Why is this a SQL syntax error?
body: <p>I have this query in Perl:</p>
  
  <pre><code>my $pkg="%";
  my $sql = "SELECT pid, CAST(pid as UNSIGNED) AS l FROM xmld ORDER BY l WHERE pkg LIKE ?";
  my $files_ref = $dbh-&gt;selectcol_arrayref($sql, undef, $pkg); 
  </code></pre>
  
  <p>It crashes with:</p>
  
  <blockquote>
    <p>DBD::mysql::db selectcol_arrayref failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE pkg LIKE '%'' at line 1 at ...</p>
  </blockquote>
  
  <p>I have been looking at this statement for hours, tried various things, but no luck.
  Where is that extra single quote coming from and how do I get rid of it?</p>