thinkphp 使用union

2021-08-24  本文已影响0人  怪力程序员
 $result1= Db::table("comm_demand")->alias('d')
                ->field('d.id art_id,d.title,d.key_word_cn,d.money_min,d.money_max,d.cooperate_name,d.date_start,d.date_end,d.status')
                ->buildSql();
            $result2= Db::table("comm_demand_talent")->alias('a')
                ->field('b.id art_id,b.title,b.key_word_cn,b.money_min,b.money_max,b.cooperate_name,b.date_start,b.date_end,b.status')
                ->where(function ($query) use ($where2) {
                    $query->where($where2);
                })
                ->where('talent_id','=','362541')
                ->join('comm_demand b','a.demand_id=b.id','LEFT')
                ->join('comm_account2_organize o','o.uid=b.uid','LEFT')
                ->union($result1,false)
                ->buildSql();
            $result = Db::table($result2.' a')
                ->field('art_id,title,key_word_cn,money_min,money_max,cooperate_name,date_start,date_end,status')
                ->page($page,'5')
                ->select();
上一篇下一篇

猜你喜欢

热点阅读