jeudi 11 juillet 2019

Where Not In using query builder

Similary with this question I need to execute the following Sql query:

SELECT COUNT(*) from table where column NOT IN (SELECT table2.id from table2 where table2.someanothercolumn >0 );

Using Eloquent's query builder, therefore I tried the following (Model Table maps into table table and Model TableTwo maps into table table2):

$enties = Table::where('id',function($q){
  $q->from('table2')->select('id')->where('someanothercolumn','>',0);
})->count();

But on the cide above how I can Place the NOT IN clause?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire