Home > database >  How to change SQL query laravel equivalent query
How to change SQL query laravel equivalent query

Time:02-11

I have written a SQL query as below

select id from users where fname not in (select fname from blocked_users);

It is working as expected. Can anyone help me to convert this to a laravel equivalent query?

Thanks.

CodePudding user response:

Try this -

DB::table('users')->whereNotIn('fname', function ($query) {
    $query->select('fname')->from('blocked_users');
})->get();
  • Related