Codeigniter Active Record Not Equal

Codeigniter mysql where not equal to query

Why dont you use simple $this->db->query('your query');

Codeigniter active record where is not working

This is an issue at the database level, though it is not a bug - this is how SQL works with null values. This query:

SELECT
*
FROM
`table`
WHERE
`user` = 24 AND `is_complete` != 1

will return records where is_complete is not equal to 1, but not null. If you wish to include null records as well, you will need to do this:

SELECT
*
FROM
`table`
WHERE
`user` = 24 AND
(`is_complete` != 1 OR `is_complete` IS NULL)

By comparing a column with a non-null value, you've automatically excluded nulls, which need to be treated with a different syntax.

You'll need to add in an additional, bracketed clause for the query; see here for how.

codeigniter: where query in not condition

Just add it to the column part of the where, so

$this->db->select('title')->from('mytable')->where('id !=', $id)->limit(10, 20);
$query = $this->db->get();

Btw, always check the codeigniter manual, it mentions it right with the where() documentation and it's one of the best documentations you are ever going to find.

CodeIgniter Active Records to compare two columns of same mysql table

Try $this->db->where('amount = discount');

Codeigniter active record get rows from two different column value

Thanks to everyone , All give me very useful advise.
I created new query base on @devpro and @cfnerd.

$this->db->where("(property_price BETWEEN $minprice AND $maxprice OR usd BETWEEN $usd_minprice AND $usd_maxprice)");

Now It work!
Thanks to all



Related Topics



Leave a reply



Submit