1. 程式人生 > >ThinkPHP5 三表聯合查詢

ThinkPHP5 三表聯合查詢

 使用ThinkPHP5 查詢構建起進行三表聯合查詢

        $account_info = Db::name('third_party_tasks')
            ->alias('a')
            ->join('third_party_taskgroups b','a.taskGroupId = b.taskGroupId')
            ->join('third_party_accounts c','b.account_id = c.id')
            ->field('c.access_token')
            ->where(['a.taskId' => $taskId])
            ->select();

具體講解可以參考ThinkPHP5.0完全開發手冊https://www.kancloud.cn/manual/thinkphp5/118083