婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > laravel join關聯查詢代碼實例

laravel join關聯查詢代碼實例

熱門標簽:百度商鋪地圖標注 新河科技智能外呼系統怎么樣 地圖標注平臺怎么給錢注冊 常州地圖標注服務商 福州人工外呼系統哪家強 釘釘打卡地圖標注 安裝電銷外呼系統 注冊400電話申請 衡水外呼系統平臺

laravel join關聯查詢

1、兩表關聯

$fbaInventoryTb = (new \App\Model\Amz\Fba\InventoryReport)->getTable();
$productTb = (new \App\Model\Amz\Product)->getTable();
$twInventoryTb = (new \App\Model\TWUsa\TwusaInventory)->getTable();
$qry = \DB::table($fbaInventoryTb);
  $qry->select($fbaInventoryTb.'.*')
   ->where($fbaInventoryTb.'.ec_id',1)
   ->leftjoin($productTb, $productTb.'.sku', '=', $fbaInventoryTb.'.sku')
   ->addSelect($productTb.'.id as goods_id',$productTb.'.sku as mfn', $productTb.'.ec_id as pro_ec_id');
//  ->where($productTb.'.ec_id',1); //不應該在此處排除 product 表的ec_id

//  return $qry->toSql();
  $res = $qry->get()->whereIn('pro_ec_id',[1, null] );//leftJion 最后排除不符合條件的

2、三表關聯

$qry = \DB::table($twInventoryTb);
  $qry->select($twInventoryTb.'.*')
   ->leftjoin($fbaInventoryTb, $fbaInventoryTb.'.fnsku', '=', $twInventoryTb.'.product_sn')
   ->addSelect($fbaInventoryTb.'.ec_id')
   ->where($fbaInventoryTb.'.ec_id',1);

  $qry->LeftJoin($productTb, $productTb.'.sku', '=', $fbaInventoryTb.'.sku')
//   ->where($productTb.'.ec_id',1)
   ->addSelect($productTb.'.id as goods_id', $productTb.'.sku as mfn', $productTb.'.ec_id as pro_ec_id');

  $res = $qry->get()->whereIn('pro_ec_id', [1, null]);

到此這篇關于laravel join 關聯查詢代碼實例的文章就介紹到這了,更多相關laravel join 關聯查詢內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • Laravel 重寫日志,讓日志更優雅
  • laravel使用組件實現微信網頁授權登入
  • Laravel統一封裝接口返回狀態實例講解
  • laravel中Join語法以及使用Join多個條件
  • laravel框架的緩存操作代碼實例
  • laravel日志優化實例講解
  • laravel下trait的使用代碼實例詳解
  • 清除laravel緩存命令代碼實例
  • 如何用Laravel包含你自己的幫助函數

標簽:六安 唐山 鷹潭 遼陽 鶴崗 白城 柳州 克拉瑪依

巨人網絡通訊聲明:本文標題《laravel join關聯查詢代碼實例》,本文關鍵詞  laravel,join,關聯,查詢,代碼,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《laravel join關聯查詢代碼實例》相關的同類信息!
  • 本頁收集關于laravel join關聯查詢代碼實例的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 阳信县| 城固县| 望江县| 江永县| 湘潭市| 习水县| 城固县| 渑池县| 敦化市| 抚松县| 武山县| 贵溪市| 开原市| 巴林左旗| 河池市| 正宁县| 长顺县| 乐山市| 双流县| 鱼台县| 余庆县| 宜兰县| 蒲江县| 宝清县| 葫芦岛市| 武川县| 凯里市| 米林县| 汪清县| 宁乡县| 阳曲县| 汉川市| 色达县| 石屏县| 淮北市| 安多县| 武冈市| 兰考县| 舒城县| 田阳县| 濮阳市|