1
在PHP laravel我使用的是如下的mysql /直接查詢:PHP Laravel:內的毗連就像條款內加入
$point_rewards = DB::select("select * from integral_history_listing INNER JOIN outlets ON integral_history_listing.branch_c LIKE CONCAT('%', outlets.outlet_code, '%') where outlets.merchant_id LIKE ".Auth::user()->id." ORDER BY integral_history_listing.add_time_c DESC");
我可以使用MySQL查詢得到任何相關的價值,出口使用類似條款代碼...但是我想使用PHP laravel查詢生成器像下面寫:
$notices = DB::table('integral_history_listing')
->join('outlets', 'outlets.outlet_code', 'LIKE', 'integral_history_listing.branch_c')
->where('outlets.merchant_id', 'LIKE', Auth::user()->id)
->orderBy('integral_history_listing.add_time_c', 'desc')
->paginate(10);
我有嘗試包括「outlets.outlet_code」但零誤差越來越模塊內CONCAT。我想知道在內部連接php laravel內部查詢中使用concat的正確方法。
我之前已經使用它。它通過零返回FatalThrowableError模。 –
仍然收到類似的錯誤消息:SQLSTATE [42000]:語法錯誤或訪問衝突:1064您的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,在'%outlets.outlet_code%'附近使用正確的語法LIKE'integral_history_listing'.'branch_c' where'outlets'at line 1(SQL:select count(*)as aggregate from CONCAT(%outlets.outlet_code%)上的'integral_history_listing'內部連接'outlet'LIKE'integral_history_listing'.''ranch_c' where'outlets'.'merchant_id'喜歡28) –
你現在可以試試,錯過了幾件事情。我希望現在能夠運作。 – Rahul