【问题标题】:Compare data from two tables in codeigniter比较codeigniter中两个表的数据
【发布时间】:2013-05-19 07:25:11
【问题描述】:

我有两个表(评论和评估),我想在 codeigniter 中执行以下 mySQL 查询。 这是 mySQL 查询:

SELECT COUNT(DISTINCT source) AS NumberOfEvaluations 
FROM COMMENT , EVALUATION
WHERE evaluation_id = EVALUATION.id AND EVALUATION.department_id = '$department_id' ;

这是我到达的更近的地方:

$this->db->select('count(DISTINCT(source))');  
$this->db->from('comment','evaluation');  

$this->db->where();  

$query=$this->db->get();  
return $query->num_rows();  

我的问题是我应该在 codeigniter 的 where 子句中检查什么?

【问题讨论】:

    标签: php mysql codeigniter phpmyadmin


    【解决方案1】:

    尝试运行这段代码:

    $this->db->select('count(DISTINCT(source))');  
    $this->db->from('comment c','evaluation e');  
    
    $this->db->where('c.evaluation_id','e.id');
    $this->db->where('e.department_id', $department_id);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-20
      • 2015-09-26
      相关资源
      最近更新 更多