select all columns which are not in another table laravel 5.5

后端 未结 4 1445
佛祖请我去吃肉
佛祖请我去吃肉 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:50

    DB::table("users")->select('*')->whereNotIn('user_name',function($query) {
    
       $query->select('user_name')->from('buy_courses');
    
    })->get();
    

    just join actually is inner join in Laravel so actually maybe also you can try:

    DB::table('users')
                ->join('buy_courses', 'users.user_name', '=', 'buy_courses.user_name')
                ->get();
    

提交回复
热议问题