Reputation: 61
I've table "tbsiswa" and i want to using QUERY " Select * FROM tbsiswa WHERE 'id_kelas' < 1 AND 'nis' != '' " I want to display data which are the id_kelas = 0 and the nis is not empty. But i've displayed none in my table using codeigniter.
so based on the table above, I want to display data:
this is what I have tried so far:
function cekSiswaNonKelas(){
$this->db->select("*");
$this->db->from("tbsiswa");
$this->db->where("id_kelas <", 1);
$this->db->where("nis", NULL, FALSE);
$siswaNonKelas = $this->db->get();
return $siswaNonKelas;
}
But based on this code above, the result is empty.
Upvotes: 0
Views: 86
Reputation: 4033
you can do this:
function cekSiswaNonKelas(){
$this->db->select("*");
$this->db->from("tbsiswa");
$this->db->where("id_kelas",0);
$this->db->where("nis!=","");
$siswaNonKelas = $this->db->get();
return $siswaNonKelas;
}
Upvotes: 1
Reputation: 128
If your column is NULL when it's empty then use:
$this->db->where("nis is NOT NULL", NULL, FALSE);
Upvotes: 1