Ad

Row Count From Second Table With More Than One Table Join

- 1 answer

I have three table:

TABLE1:

jobposts (id,user_id,qualification_id)

TABLE2:

appliedjobs (id,jobposts_id,message)

TABLE3:

qulificationmasters (id, qualificationame)
jobposts_id from TABLE is foreign key of id of jobposts

I need all records from jobposts with row count of appliedjobs

I tried by this:

$jobposteddetails = DB::table('jobposts')
    ->rightJoin('qulificationmasters','qulificationmasters.id', '=', 'jobposts.qualification_id')   
    ->leftJoin('appliedjobs','appliedjobs.jobposts_id', '=', 'jobposts.id')
   ->select('jobposts.*','qulificationmasters.QualificationName', DB::raw('count(appliedjobs.id) as counts'))
            ->where('jobposts.user_id', '=', $user->id)
            ->groupBy('appliedjobs.id')
            ->get();

But gives error like: it wants every column in groupby of jobposts and qulificationmasters and qulificationmasters.id

But gives error like: it wants every column in groupby of jobposts and qulificationmasters and qulificationmasters.id

If I groupby with all columns of jobposts and qulificationmasters then it is working good. But why all the columns gropuby.

Ad

Answer

Go in config folder database.php find mysql array and make strict to false and check again.

Ad
source: stackoverflow.com
Ad