Mysql 从数据库中选择时出现错误编号:1064
当从下面的数据库中选择图像时,会显示错误&在我删除数据库中的记录后,其内部的数字(id)保持不变 这就是错误所在Mysql 从数据库中选择时出现错误编号:1064,mysql,sql,Mysql,Sql,当从下面的数据库中选择图像时,会显示错误&在我删除数据库中的记录后,其内部的数字(id)保持不变 这就是错误所在 Error Number: 1064 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 '16,19,1,2,1,2,1 )' at line 1 se
Error Number: 1064
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 '16,19,1,2,1,2,1 )' at line 1
select * from images where id in(,16,19,1,2,1,2,1 )
Filename: controllers/Admin.php
Line Number: 1046
这是选择状态:
if (!empty($data->images)) {
$qry = $this->db->query("select * from images where id in($data-
>images )");
$res['results'] = $qry->result();
}
现在我的数据库是空的,这个错误仍然存在?只需删除前面的逗号。像这样
select * from images where id in( 16,19,1,2,1,2,1 )
$data->images
中有一个前导逗号。错误消息本身说这是MySQL-不是SQL Server-删除了错误的标记,添加了MySQL
instead。看起来您的参数源有一个前导逗号。逗号。继续。(,16,19,1,2,1,1,2,1)
请参见我看到的16oki之前的内容,但在代码中如何找到这些数字??ana select语句中没有这样的数字,如果它是一个字符串,您可以使用trim($data->images,,')
。在选择station之前,它将删除任何前导字符,但如果(!empty($data->images)){trim($data->images',,');$qry=$this->db->query(“select*from images where id in($data->images)”;$res['results']=$qry->result();}