하이 CodeIgniter의 다른 컬럼에없는 하나 개의 컬럼에서 레코드를 얻고, 난이내가 CodeIgniter를 사용하고
PreferenceID
값이없는 경우에는 내가 모든 레코드를 얻으려면 같은 테이블이하는 방법 PreferenceParentID
열
이 경우 나는 또한 EntityID
과 함께 fitering 테이블입니다. 및 PreferenceParentID
두 경우 모두 PreferenceParentID
에없는
Couture , Denims
PreferenceID
때문에 내 결과가 될 말아야 entityID
53
에 의해 != 0
가정 해 전 필터가 될 말아야. 나는 where_not_in()
으로 시도했지만 할 수 없었습니다. 이 내 쿼리
도와주세요
$table = $this->mastables['shop_profile_preferences'];
$this->db->select('a.ProfilePreferenceID');
$this->db->from($table." as a");
$where2 = "(SELECT a.PreferenceParentID FROM ".$table.")";
$this->db->where_not_in('a.PreferenceID', $where2);
$this->db->where("a.EntityID",$shop_id);
$this->db->where('a.PreferenceParentID !=',0);
$query=$this->db->get();
if($query->num_rows()>0)
{
return $query->result_array();
}
else
{
return FALSE;
}
내 쿼리의 결과는
Array
(
[0] => Array
(
[ProfilePreferenceID] => 274
)
[1] => Array
(
[ProfilePreferenceID] => 275
)
[2] => Array
(
[ProfilePreferenceID] => 276
)
)
어떻게 제대로
where_not_in()
을 사용하는 것입니다. 거기에 다른 방법이 있습니다. 제발 도와주세요 ..... 미리 감사드립니다.
UPDATE
$table = $this->mastables['shop_profile_preferences'];
$this->db->select('a.ProfilePreferenceID,a.ProfilePreferenceValue');
$this->db->from($table." as a");
$this->db->where('a.PreferenceParentID !=',0);
$this->db->where('a.PreferenceID NOT IN (SELECT a.PreferenceParentID FROM '.$table.')', NULL, FALSE);
$this->db->where("a.EntityID",$shop_id);
$query=$this->db->get();
if($query->num_rows()>0)
{
return $query->result_array();
}
else
{
return FALSE;
}
mm 여전히 작동하지 않습니다. 다시 연결됩니다. –
내 쿼리를 $ this-> db-> where ('a.PreferenceID NOT IN (SELECT a.PreferenceParentID FROM'. $ table. ')', NULL, FALSE)로 변경했습니다. –
@KanishkaPanamaldeniya 업데이트 된 코드로 게시물을 업데이트 할 수 있습니까? –