首页 > 解决方案 > 在 Eloquent Laravel 中使用左连接进行更新不起作用

问题描述

我正在尝试使用左连接进行更新

    CurrencyShop::from('ps_currency_shop')->leftJoin('ps_currency', 'ps_currency.id_currency', '=', 'ps_currency_shop.id_currency')
    ->where('ps_currency.conversion_rate', 2)
    ->update(['ps_currency_shop.conversion_rate' => \DB::raw('ps_currency.conversion_rate')]);
    dump(DB::connection('mysql_remote')->getQueryLog());

查询日志看起来不错。但没有更新 :((( 有同样问题的人,请 laravel 5.6 版

标签: laraveleloquent

解决方案


WhereRaw 解决了问题

->whereRaw('ps_currency.id_currency', 'ps_currency_shop.id_currency')

推荐阅读