【发布时间】:2016-12-26 11:53:52
【问题描述】:
就我而言
$products = $products->select(array('products.*', \DB::raw('COUNT(extra_fields.price) as price_count')))->leftJoin('extra_fields', 'products.id', '=', 'extra_fields.item_id')
->where('item_type', 'App\Models\Product')
->whereRaw("price = '0'")
->whereRaw("price_count = 1")
->groupBy('item_id')
->groupBy('price')
;
当我想在 where 或 whereRaw 中使用 { price_count } 时:
Column not found: 1054 Unknown column 'price_count'
price_count 只能以这种方式工作:
->orderBy('price_count')
我如何在 where 或 whereRaw 上使用 price_count ?
有什么建议吗?
【问题讨论】: