[
[
'goods_id' => 1,
'attr_item' => '49,52'
], [
'goods_id' => 1,
'attr_item' => '49,51'
]
]我想查询这样一个条件 goods_id=1 && attr_item =="49,52 || goods_id=1 && attr_item =="49,51"这样的多字段组成唯一性 要怎么写呢
1 回答
回首忆惘然
TA贡献1847条经验 获得超11个赞
用闭包查询
$result = Db::table('think_user')->where(function ($query) { $query->where('id', 1)->whereOr('id', 2); })->whereOr(function ($query) { $query->where('name', 'like', 'think')->whereOr('name', 'like', 'thinkphp'); })->select();
生成的sql语句类似于下面
SELECT * FROM `think_user` WHERE ( `id` = 1 OR `id` = 2 ) OR ( `name` LIKE 'think' OR `name` LIKE 'thin
- 1 回答
- 0 关注
- 1562 浏览
添加回答
举报
0/150
提交
取消