sql - Fastest way to find count of selected items in MySql? -
i know how find count,avg functions works want i'm trying achieve here operation after count found please see code below. article::where('id','=',130) ->select( 'articles.*', db::raw('(select avg(rating) rating rateable_id = articles.id , type = "article" ) avgrating'), db::raw('(select count(*) comments commentable_id = articles.id , commentable_type = "article") commentcount'), db::raw('(select count(*) article_favourites article_id = articles.id ) favouritecount') ) ->get(); using above query, can 'avgrating', 'commentcount', 'favouritecount', want sum of these three.. i.e. like: (avgrating + commentcount + favouritecount) sum what best way this? ps: have solution db::raw('( (select avg(rating) rating rateable_id = article.id , type = "article")+(select co...