Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 从数据库中选择时出现错误编号:1064_Mysql_Sql - Fatal编程技术网

Mysql 从数据库中选择时出现错误编号:1064

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

当从下面的数据库中选择图像时,会显示错误&在我删除数据库中的记录后,其内部的数字(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

 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();}