简体   繁体   English

Laravel查询选择具有多个值匹配的单列

[英]Laravel query select single column with multiple value matches

Laravel query select single column with multiple value matches Laravel查询选择具有多个值匹配的单列

$user = User::where('name', [
        'User1',
        'User2',
        'User3',
    ])->get();

You're looking for whereIn() : 您正在寻找whereIn()

$user = User::whereIn('name', ['User1', 'User2', 'User3'])->get();

where() is used for single values, but whereIn() uses an array to match against the given column. where()用于单个值,但是whereIn()使用数组来匹配给定的列。

Check https://laravel.com/docs/5.8/queries#where-clauses for full details. 查看https://laravel.com/docs/5.8/queries#where-clauses了解完整详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM