Laravel Ask WHERE NOT IN

0

I have the following SQL query

SELECT * from autor where autor.Id_autor not in 
       (select ca.fk_autor from cntrl_autor ca 
        join autor a on a.Id_autor = ca.fk_autor 
        where ca.fk_doc=7993)

How can I convert it to how the Laravel query builder handles it?

    
asked by Ccin 30.03.2018 в 00:14
source

1 answer

0

You can use DB :: RAW and pass your query or you can use the following

DB::table('autor')
  ->whereNotIn('Id_autor', DB::table('cntrl_autor')
  ->join('autor', 'cntrl_autor.fk_autor', '=', 'autor.Id_autor')
  ->where('cntrl_autor.fk_doc', 7993)
  ->pluck('autor.Id_autor')->values());
    
answered by 02.04.2018 в 13:56