Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0
Solution

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();
Last updated 2 years ago.
0

Thanks a lot

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Haseeb90 haseeb90 Joined 8 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.