您好,登錄后才能下訂單哦!
$where['enterprise_id'] = $enterpriseId; //企業名稱不為空 if(!empty($enterpriseName)){ $where['enterprise_name'] = array('like',"%$enterpriseName%"); } $table2 = array('enterprise_data.yunkh_enterprise_rel_enterprise'=>'ed_ere', 'enterprise_data.yunkh_enterprise_info'=>'ed_ei'); $where2 = array('ed_ere.enterprise_id'=>$enterpriseId, 'status'=>'1', 'ed_ei.enterprise_name'=>array('like',"%$enterpriseName%"), '_string'=>'ed_ere.rel_enterprise_id = ed_ei.enterprise_id'); $contractInfoList = $this->model->field('enterprise_id,enterprise_name') ->table(array('enterprise_data.yunkh_enterprise_info' => 'ed_id')) ->where($where) ->union(array('field'=>'ed_ei.enterprise_id,enterprise_name','table'=>$table2,'where'=>$where2),true) ->select(); return $contractInfoList; 執行的sql: SELECT 'enterprise_id','enterprise_name' FROM enterprise_data.yunkh_enterprise_info 'ed_id' WHERE 'enterprise_id' = 1 AND 'enterprise_name' LIKE '%農%' UNION ALL SELECT ed_ei.enterprise_id,'enterprise_name' FROM enterprise_data.yunkh_enterprise_rel_enterprise 'ed_ere',enterprise_data.yunkh_enterprise_info 'ed_ei' WHERE ed_ere.enterprise_id = 1 AND 'status' = '1' AND ed_ei.enterprise_name LIKE '%農%' AND ( ed_ere.rel_enterprise_id = ed_ei.enterprise_id )
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。