Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

This query, return this error.

operator does not exist: text = integer LINE 2: from mas_book ) as outp where outp.authors = 2 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts

public function authors($ids)
{
  $query = "select count(authors) from (select distinct regexp_split_to_table(author, E',') as authors
        from mas_book ) as outp where outp.authors = ".$ids;
        $result =   $this->db->query($query);
     return $result->result();
}
share|improve this question

2 Answers 2

up vote 1 down vote accepted

If outp.authors value can be converted into Integer then You can use :

"select count(authors) from (select distinct regexp_split_to_table(author, E',') as authors
        from mas_book ) as outp where to_number(outp.authors,'9999999') = ".$ids; 

If It is work then See this Link

share|improve this answer
 SELECT COUNT(authors) FROM (SELECT DISTINCT regexp_split_to_table(author, E',') as authors
            FROM mas_book ) as outp WHERE outp.authors = ".'cast(.'$ids'. as character varying);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.