'having clause'.column中的未知列'erp_purchase_order_details.received'出现在表格中,但它显示上述错误
代码:
$status_result = DB::table('erp_purchase_order_details')->select(DB::raw('COUNT(erp_purchase_order_details.product_category_id) as count_products'),DB::raw('COUNT(erp_purchase_order_details.received) as count_received'))
->havingRaw('erp_purchase_order_details.received > 1')
->where('erp_purchase_order_details.purchase_order_id','=',$purchase_order_id)
->get();
答案 0 :(得分:0)
在HAVING
子句条件中,您应该只使用聚合函数,而不是:
->havingRaw('erp_purchase_order_details.received > 1')
如果条件是关于列的,则将其移至WHERE
子句,否则使用适当的聚合函数,如COUNT
等。