超过一个 table 连接的第二个 table 的行计数

row count from second table with more than one table join

我有三个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

我需要职位发布中包含已申请职位行数的所有记录

我试过这个:

$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();

但给出如下错误:它需要 jobposts 和 qulificationmasters 的 groupby 中的每一列和 qulificationmasters.id

但给出如下错误:它需要 jobposts 和 qulificationmasters 的 groupby 中的每一列和 qulificationmasters.id

如果我对所有工作职位和资格认证列进行分组,那么它运行良好。 但是为什么所有的列都是 gropuby。

进入配置文件夹 database.php 找到 mysql 数组并将严格设置为 false 并再次检查。