[英]Why is this a SQL syntax error?
I have this query in Perl: 我在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;
DBD :: mysql :: db selectcol_arrayref失败:SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE pkg LIKE '%'' at line 1 at ...
检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第1行的'WHERE pkg LIKE'%'附近使用...
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?
那多余的单引号从哪里来?我如何摆脱它?
order by
goes after the where
: order by
后去where
:
SELECT pid, CAST(pid as UNSIGNED) AS l
FROM xmld
WHERE pkg LIKE ?
ORDER BY l;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.