0

when i use $this->db->where('field !=', 1);

i want to select all entries where field is not 1. so that means here 0 or NULL however in codeigniter he doesn't select it where the entry is NULL (default value).

how to solve this without changing the database?

dave

1 Answer 1

2

NULL values need to be handled separately with another where clause:

$this->db->where('field <>', 1)->or_where('field IS NULL', NULL);

It has nothing to do with Codeigniter. It's a MySQL matter.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks! actually had to do it this way $this->db->where("(field != 1 OR field IS NULL)"); because of the OR. there should be a cleaner way in codeigniter but don't think there is one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.