SQLSTATE [42S22]:找不到列:1054“字段列表”中的未知列“ transaction_sell_lines.name”

时间:2019-05-29 07:01:27

标签: php laravel

  

DataTables警告:表格ID = product_sell_report_table-异常消息:

     

SQLSTATE [42S22]:找不到列:1054'字段列表'中的未知列'transaction_sell_lines.name'

控制器

$brands=DB::table('products') 
    ->select('brands.name') 
    ->join('brands','brands.id','=','products.brand_id')
    ->join('transaction_sell_lines','products.brand_id','=','transaction_sell_lines.product_id') 
    ->get();

'transaction_sell_lines.name as brand',

jquary {data: 'brands',name:'transaction_sell_lines.brand'},

1 个答案:

答案 0 :(得分:1)

您需要提供DB::raw才能获取此类数据

DB::raw('transaction_sell_lines.name as brand'),

像上面一样。

现在再次检查。