重复的列名“ id” CODEIGNITER

时间:2019-03-12 01:48:05

标签: php sql codeigniter

嗨,我不明白为什么会有这个错误

这是一个查询:

function get_num_post($args = array()) {
    $this->db->from("diario");
    if (isset($args["tag"]) && $args["tag"]) :
        $this->db->join("diario_tag_rif","diario_tag_rif.post_id = diario.id");
        $this->db->group_by("diario.id");
        $this->db->where("diario_tag_rif.tag_id",$args["tag"]->id);
    endif;
    if (isset($args["anno"]) && $args["anno"]) :
        $this->db->where("YEAR(diario.data)",$args["anno"]);
    endif;
    if (isset($args["mese"]) && $args["mese"]) :
        $this->db->where("MONTH(diario.data)",$args["mese"]);
    endif;
    $this->db->join("diario_categorie","diario_categorie.id = diario.categoria_id");
    return $this->db->count_all_results();
}

请帮助我解决我的问题?非常感谢:)

1 个答案:

答案 0 :(得分:0)

在使用where之前,您应该先加入,然后在where子句中使用group by。

相关问题