企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
>[info] Join关联查询 * ThinkPHP6 ~~~ $menuModel = new Menu(); $menuList = $menuModel->alias('m') ->join(DB_PREFIX . 'role_menu rm', 'rm.menu_id=m.id') ->join(DB_PREFIX . 'user_role ur', 'ur.role_id=rm.role_id') ->distinct(true) ->where('ur.user_id', '=', $userId) ->where('m.type', '=', 0) ->where('m.pid', '=', $pid) ->where('m.status', '=', 1) ->where('m.mark', '=', 1) ->order('m.pid ASC,m.sort ASC') ->field('m.*') ->select()->toArray(); $check_list = Db::name('FlowRecord') ->field('f.*,a.name,a.thumb') ->alias('f') ->join('Admin a', 'a.id = f.check_user_id', 'left') ->where(['f.action_id'=>$id,'f.type'=>$type]) ->order('check_time asc') ->select()->toArray(); ~~~ * Laravel6 ~~~ // 查询db_erp_boss 数据集 $admin = DB::connection('db_erp_boss')->table('admin_users') ->leftJoin('admin_token','admin_users.id','=','admin_token.user_id') ->leftJoin('admin_roles','admin_roles.role_id','=','admin_users.user_role') ->where('admin_token.token',$requestData['token']) ->select( 'admin_token.login_ip', 'admin_roles.role_name', 'admin_token.user_id', 'admin_token.login_ip', 'admin_users.*', 'admin_token.expire_time' )->first(); ~~~ * mysql ``` SELECT tbl_server_info.company AS '商家名称', USER.username AS '用户名称' FROM `tbl_server_info` JOIN `user` ON tbl_server_info.server_id = USER.server_id WHERE tbl_server_info.category_list LIKE "%phone%" ``` ``` SELECT `t`.`category`, `t`.`sku_id`, `t`.`parent_key`, `t`.`scheme_title`, `t`.`sku_name`, `t`.`cover`, `rental`, `t`.`deposit`, `t`.`suffix`, `t`.`server_id`, `p`.`indi_city` FROM `code_merch_item_statistics` `s` LEFT JOIN `index_cate` `t` ON s.sku_id = t.sku_id LEFT JOIN `es_city_push` `p` ON s.sku_id = p.parent_key WHERE ( ( `t`.`category` IN ( 'new_phone', 'new_computer', 'new_tablet', 'new_photography', 'new_game', 'new_uav', 'new_entertainment', 'new_tourism' ) ) AND ( `t`.`status` = 10 ) ) AND ( t.parent_key = t.sku_id ) AND ( `t`.`server_id` != NULL ) AND ( p.indi_city <> "" ) AND ( `s`.`is_choice` = 1 ) ORDER BY `s`.`id` DESC LIMIT 10 ```