Mysql 如何获取用户尚未应用的所有广告

Mysql 如何获取用户尚未应用的所有广告,mysql,Mysql,我不知道我是否应该编辑为旧问题,因为答案昨天对我有效,但由于一些变化,它不再有效。关于这一点: 我必须填写表格,job\u发布和job\u应用。我怎样才能得到用户未申请的所有工作 以下是我的job\u公告表的列: id, user_id, title, description, duties, salary, child_count, benefits, created_at, updated_at, deleted_at 下面是作业应用的列表 user_id, posting_id, sta

我不知道我是否应该编辑为旧问题,因为答案昨天对我有效,但由于一些变化,它不再有效。关于这一点:

我必须填写表格,
job\u发布
job\u应用
。我怎样才能得到用户未申请的所有工作

以下是我的
job\u公告表的列:

id, user_id, title, description, duties, salary, child_count, benefits, created_at, updated_at, deleted_at
下面是
作业应用的列

user_id, posting_id, status, created_at, updated_at, deleted_at
我尝试的是:

    $job_postings =  DB::table('job_postings')
        ->select(
          'job_postings.title',
          'job_postings.description',
          'job_postings.duties',
          'job_postings.salary',
          'job_postings.child_count',
          'job_postings.benefits',
          'job_postings.created_at',
          'job_postings.id AS posting_id',
          'job_applies.status')
        ->leftJoin('job_applies', function($join)
          {
              $join->on('job_applies.posting_id', '=', 'job_postings.id')
              ->on('job_applies.user_id', '=', 'job_postings.user_id');
          })
          ->where('job_applies.status', "!=", 1)
          ->whereNull('job_postings.deleted_at')
          ->whereNull('job_applies.posting_id')
        ->get();
但这给了我0个结果。目前有两份工作申请,分别为
id=1
id=2
一份工作申请id=1的申请
job_applications.status=1
表示用户已申请该作业

编辑 为了澄清,如果用户取消应用作业,它会将
状态更新为4,这意味着已取消,因此实际上不会从job\u applicates表中删除行


上面的查询仍然给我0个结果。如何获取作业?

也允许状态列为空值

   $job_postings =  DB::table('job_postings')
            ->select(
              'job_postings.title',
              'job_postings.description',
              'job_postings.duties',
              'job_postings.salary',
              'job_postings.child_count',
              'job_postings.benefits',
              'job_postings.created_at',
              'job_postings.id AS posting_id',
              'job_applies.status')
            ->innerJoin('job_applies', function($join)
              {
                  $join->on('job_applies.posting_id', '=', 'job_postings.id')
                  ->on('job_applies.user_id', '=', 'job_postings.user_id');
              })
              ->where('job_applies.status', "!=", 1)
              ->whereNull('job_applies.status')
              ->whereNull('job_postings.deleted_at')
              ->whereNull('job_applies.posting_id')
            ->get();