-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();
}
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Shiva Prakashan
  • 99
  • 1
  • 10

2 Answers2

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

Community
  • 1
  • 1
Shubham Batra
  • 2,357
  • 5
  • 29
  • 48
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);
Shubham Batra
  • 2,357
  • 5
  • 29
  • 48
satish kilari
  • 746
  • 4
  • 21