3

Somehow its a bit difficult to for me to build a query like this: Give me all entries of navigation where linkname not null

$query = $this->db->get_where('navigation',array('linkname'!==NULL));

Giving me Error

Unknown column '0' in 'where clause'

SELECT linkname, idnavigation FROM (navigation) WHERE 0 = 1

Any hints with this?

Jurudocs
  • 8,595
  • 19
  • 64
  • 88
  • 1
    Dunno why this question has been downvoted. Helped me. I had `$query = $this->db->get_where('table', array('column', 'value'));` and had this issue. Needed to change `'column', 'value'` to `'column' => 'value'`. Silly error, but thanks for helping. :) – Thomas Clayson Jun 15 '12 at 14:38
  • Possible duplicate [querying-mysql-with-codeigniter-selecting-rows-where-field-is-null](http://stackoverflow.com/questions/2489453/querying-mysql-with-codeigniter-selecting-rows-where-field-is-null/13995884#13995884) – None Mar 15 '13 at 01:03

4 Answers4

12

You can simply write the WHERE clause manually like this:

$this->db->get_where('navigation', 'linkname IS NOT NULL');
Colin Brock
  • 21,267
  • 9
  • 46
  • 61
1

It's :

$query = $this->db->get_where('navigation',array('linkname !=' => NULL));
  • 1
    I think its important to note that there should be a space between the field name and the operator (i.e 'linkname!=' will not work) – Eric Kigathi Apr 21 '12 at 18:06
0

Try this one...

$this->db->select("*)
->from("table_name")
->where("your_id <>",'');
Raham
  • 4,781
  • 3
  • 24
  • 27
-2
$this->db->where('linkname !==', NULL);
$query = $this->db->get('navigation');
csotelo
  • 1,453
  • 2
  • 28
  • 43