COUNT related rows from a JOINed table with CodeIgniter's query builder [duplicate]
I have a raw SQL query that works, but I want to convert it to CodeIgniter's query builder methods. Raw query: SELECT online_visitors.page_id, hotels.hotel_name, COUNT(online_visitors.page_id) AS count_visit FROM `online_visitors`, `hotels` WHERE online_visitors.page_type = 'hotel' AND online_visitors.is_bot = 0 AND hotels.ID = online_visitors.page_id GROUP BY online_visitors.page_id ORDER BY online_visitors.page_id ASC My unsuccessful coding attempt which is at least missing the COUNT part: $this->db->select("page_id, hotel_name"); $this->db->from("hotels"); $this->db->join("online_visitors")
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.