dqmdlo9674 2018-01-08 11:49 采纳率: 100%
浏览 74

检查SQL语法 - 相同的模型代码适用于Codeigniter模型函数中的另一个数据库

I am getting the following error, with the code below i am not getting any error on another db, but getting error on the first one, no clue whats happening, i am using codeigniter 1x and ver 10.1.25-MariaDB

A Database Error Occurred Error Number: 1064

    You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' jp.departmentid ) >0 and FIND_IN_SET( 0, jp.designation ) >0 and FIND_IN_SET( ,' at line 1

    SELECT DISTINCT d.id as did, departmentname,GROUP_CONCAT(DISTINCT jp.id) as policy_ids,GROUP_CONCAT(DISTINCT policy_title) as policies FROM `pr_policy` jp INNER JOIN `pr_departments` d ON FIND_IN_SET( d.id, jp.departmentid ) >0 INNER JOIN `pr_designation` des ON FIND_IN_SET( des.id, jp.designation ) >0 LEFT OUTER JOIN `pr_office_branches` o ON FIND_IN_SET( o.id, jp.branchid ) >0 WHERE FIND_IN_SET( , jp.departmentid ) >0 and FIND_IN_SET( 0, jp.designation ) >0 and FIND_IN_SET( , jp.branchid ) >0 group by jp.id,d.id,des.id

    Filename: /var/www/html/login/models/mod_common.php

    Line Number: 7582

The model - mod_common.php function is as below

function get_full_policies_user() { $sql = "SELECT jp.*,jp.id as id,GROUP_CONCAT(DISTINCT d.departmentname) as department,GROUP_CONCAT(DISTINCT des.designation) as designation,jp.create_date,GROUP_CONCAT(DISTINCT o.branchname) as branch,jp.policy_title,jp.create_date
FROM `".$this->myTables['policy']."` jp INNER JOIN `".$this->myTables['department']."` d ON FIND_IN_SET( d.id, jp.departmentid ) >0 INNER JOIN `".$this->myTables['designation']."` des ON FIND_IN_SET( des.id, jp.designation ) >0 LEFT OUTER JOIN `".$this->myTables['office']."`
o ON FIND_IN_SET( o.id, jp.branchid ) >0 "; if($jdid > 0) { $sql .= " where jp.id=".$jdid; } $sql .=" group by jp.id,d.id,des.id"; //echo $sql;die(); $query=$this->db->query($sql); if($query->num_rows() > 0){ $rows = $query->result(); } return $rows;
}

The database tables are as attached - pr_policy, pr_departments, pr_designation

enter image description here

enter image description here

enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测