错误号码:1064
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近')和qbank.institute_id =' 1'按字段排序(qid,)'在第1行
SELECT * FROM `qbank` JOIN question_category ON qbank.cid = question_category.cid WHERE qbank.qid IN ( ) and qbank.institute_id ='1' ORDER BY FIELD( qid, )
以下是完整代码:
function get_question($rid){
$institute_id = $this->session->userdata('institute_id');
$query = $this -> db -> query("select quiz_result.* from quiz_result where rid='$rid' and institute_id='$institute_id'");
$row=$query->row_array();
$qids=$row['qids'];
$query = $this -> db -> query("SELECT * FROM `qbank` JOIN question_category ON qbank.cid = question_category.cid WHERE qbank.qid IN ( $qids ) and qbank.institute_id ='$institute_id' ORDER BY FIELD( qid, $qids )");
$questions=$query->result_array();
$query = $this -> db -> query("SELECT * FROM q_options WHERE qid IN ( $qids ) and institute_id = '$institute_id'");
$options=$query->result_array();
$dataarr=array($questions,$options);
return $dataarr;
}
答案 0 :(得分:0)
有2个语法错误。
你不能有一个空列表()
你没有字段就在订单中有一个commma。 (qid,)
答案 1 :(得分:0)
准备以下声明并分享准备好的声明/查询以检查确切的问题 -
SET @qry=CONCAT("SELECT * FROM qbank JOIN question_category ON qbank.cid = question_category.cid WHERE qbank.qid IN ( ",$qids,") AND qbank.institute_id ='",$institute_id,"' ORDER BY FIELD( qid, ",$qids,")")
可能的原因:您以无效格式传递参数值。