-1

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();
}
0

2 Answers 2

3

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 not work then See this Link

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

Comments

3
 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);

Comments

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.