Hi Haseeb, You should not use the user input directly inside a raw query expression. Neways I hope this solves your problem:
$users = DB::table("feedMentions")
->select(
DB::raw('taggedUserName'),
DB::raw('COUNT(taggedUserId) AS freq')
)
->whereRaw(DB::raw('postId IN (SELECT postId FROM feedPosts WHERE postedByUserName = :userId)'),['userId'=>$userId])
->groupBy('taggedUserId')
->orderBy('freq', 'DESC')->get();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community