-2

I wrote a query to get count of entries in SQL table I was using active record in CodeIginitor

This code is not working ... saying error in query line

$this->db->query('SELECT COUNT(*) FROM site UNION SELECT COUNT(*) FROM userdata'); 
$result=$this->db->get();
return $result->result();

I searched to get a corresponding active record query but have not got any result

octano
  • 851
  • 1
  • 10
  • 18
Aly Hunzik
  • 27
  • 8

1 Answers1

-1
 $this->db->query(
    '(SELECT COUNT(*) as count_site FROM site) 
    UNION 
    (SELECT COUNT(*) as count_userdata FROM userdata)'
 );
 return $query->result();
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
  • 5
    Your code snippet seems to be helpful, but you should explain what is wrong with the OPs code and how you fixed it. – Thomas Urban Nov 05 '18 at 16:18