我们可以使用不相等的whereIn子句吗

时间:2019-03-07 06:51:21

标签: php mysql laravel eloquent

我需要遵循

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

那么我该如何做到这一点。任何建议谢谢。

4 个答案:

答案 0 :(得分:7)

您可以使用whereIn代替whereNotIn

赞:

Model::select('column')->whereNotIn('column', array(1,2,3))->first();

答案 1 :(得分:5)

您正在寻找whereNotIn('column', $array)。有关更多方法,请参见Queries文档。

答案 2 :(得分:5)

使用

Model::whereNotIn('id',[10,20])->select('id')->first();

浏览Laravel Eloquent “WHERE NOT IN”

答案 3 :(得分:4)

尝试一下:

Model::select('column')->whereNotIn('column',array)->first();
相关问题