Codeginter $this->db->where() function concating "IS NULL" in query automatically when using find_in_set() function

StackOverflow https://stackoverflow.com/questions/17511637

  •  02-06-2022
  •  | 
  •  

Domanda

I am writing a query in codeigniter with FIND_IN_SET() function.

   $this->db->where(FIND_IN_SET('".$value."',employer_job_location));
    $query_res= $this->db->get("employer_posted_jobs");
   echo $this->db->last_query(); exit;

It is yielding

SELECT * 
FROM (`employer_posted_jobs`) 
WHERE (FIND_IN_SET('Delhi',employer_job_location)) IS NULL

In above query "IS NULL" is extra and it is very annoying. Can anyone tell why this is coming with the query? Thank you..

È stato utile?

Soluzione

You must always check the results from the FIND_IN_SET() function somehow to make it work, try this:

$this->db->where("FIND_IN_SET('$value',employer_job_location) !=", 0);

Altri suggerimenti

$this->db->where("FIND_IN_SET('$value',employer_job_location) !=", 0);

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top