thinkphp 如果有个whereIn,如何限定查询范围
时间: 2023-03-29 09:00:16 浏览: 55
可以使用where条件来限定查询范围,例如:
$ids = [1, 2, 3];
$result = Db::table('table_name')->whereIn('id', $ids)->where('status', 1)->select();
这样就可以查询id在1、2、3之间且状态为1的数据。
相关问题
thinkphp 如果有2个whereIn,如何限定查询范围
您可以使用where条件来限定查询范围,例如:
$ids1 = [1, 2, 3];
$ids2 = [4, 5, 6];
$result = DB::table('table_name')
->whereIn('id', $ids1)
->whereIn('id', $ids2, 'and', true)
->get();
这样,第二个whereIn查询的结果将会在第一个whereIn查询的结果的基础上再次筛选,从而限定查询范围。
thinkphp whereIn 如何限定查询范围
可以使用whereIn方法来限定查询范围,例如:
$ids = [1, 2, 3];
$results = DB::table('table_name')->whereIn('id', $ids)->get();
这样就可以查询id为1、2、3的记录了。