alexistdev
alexistdev

Reputation: 61

Query in codeigniter WHERE "LESS THAN 1" AND "NOT NULL" result None

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:

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

Answers (2)

PHP Geek
PHP Geek

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

mhepton
mhepton

Reputation: 128

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

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

Upvotes: 1

Related Questions