select all columns which are not in another table laravel 5.5

后端 未结 4 1367
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 04:05

I have two tables - the first one is called \'users\' and the second one is called \'buy_courses\'.

I am trying to select all users those user_name

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-12 04:25

    just replace = with != , use function join

    $users = DB::table('users')
      ->join(
        'buy_courses', 
        function ($join)
        {$join->on('users.user_name', '!=', 'buy_courses.user_name');}
      )
      ->get();
    

提交回复
热议问题