2016-12-06 42 views
0

我有一個表有幾列的views_answers,其中三個在這種情況下感興趣我opinion_iddate_answerid_politician如何查詢同一列中所有具有不同值的行

我需要查詢所有具有特定opinion_id的行,其date_answer!=「」和id_politician總是不同。

我有這樣的:

$this->db->from("opinions_answers"); 
$this->db->where("opinion_id", 1); 
$this->db->where("date_answer !=", ""); 
return $this->db->count_all_results(); 

它的工作原理,但我不知道如何指定列id_politician必須包含每行中不同的值...

任何想法? 謝謝

回答

2

這應該做到這一點。

$this->db->from("opinions_answers"); 
$this->db->where("opinion_id", 1); 
$this->db->where("date_answer !=", ""); 
$this->db->group_by('id_politician'); 
return $this->db->count_all_results(); 
相關問題