Reputation: 1018
I have this query in Perl:
my $pkg="%";
my $sql = "SELECT pid, CAST(pid as UNSIGNED) AS l FROM xmld ORDER BY l WHERE pkg LIKE ?";
my $files_ref = $dbh->selectcol_arrayref($sql, undef, $pkg);
It crashes with:
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 ...
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?
Upvotes: 0
Views: 193
Reputation: 1269703
order by
goes after the where
:
SELECT pid, CAST(pid as UNSIGNED) AS l
FROM xmld
WHERE pkg LIKE ?
ORDER BY l;
Upvotes: 6