一、查询一个列的数值等于一个变量,并且另外一列的数据不是为零就是为空
查询表wip_operation_plan,
当列wip_entity_name为变量$wip_entity_name
并且另外一列begin_quantity为空,或者为0
查询满上述条件的operation_code列的所有值
$data = Db::table('wip_operation_plan')
->where(['wip_entity_name'=>$wip_entity_name])
->where(function ($query) {
$query->where('begin_quantity',null)
->whereOr('begin_quantity','=',0); // 判断另外一列是否为0
})
->column('operation_code');
二、查询条件单行满足:一列的数值大于另外一列的数值
对表wip_operation_plan进行查询条件有:
①表中数据begin_quantity类要大于input_quantity这一列的值
②wip_entity_name等于变量$wip_entity_name
Db::table('wip_operation_plan')
->whereRaw('begin_quantity > input_quantity')
->where(['wip_entity_name' => $wip_entity_name])
->select();