Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we use whereIn clause with not equal

I need to do following

Model::select('column')->whereIn('column','!=',array)->first();

So how can i achieve this. Any suggestions Thank you.

like image 231
Riaz Khan Avatar asked Mar 07 '19 06:03

Riaz Khan


2 Answers

Instead of whereIn you can use whereNotIn.

Like this:

Model::select('column')->whereNotIn('column', array(1,2,3))->first();
like image 51
Inzamam Idrees Avatar answered Sep 30 '22 05:09

Inzamam Idrees


You are looking for whereNotIn('column', $array). See the Queries documentation for more methods.

like image 25
FatBoyXPC Avatar answered Sep 30 '22 03:09

FatBoyXPC