I've table "tbsiswa" and i want to using QUERY " Select * FROM tbsiswa WHERE 'id_kelas' < 1 AND 'nis' != '' " enter image description here 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:

  • mantha
  • ciput

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.

2 Answers

1
mhepton On

If your column is NULL when it's empty then use:

$this->db->where("nis is NOT NULL", NULL, FALSE);

1
PHP Geek On

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;
    }