巢狀查詢 使用多個collection

2021-10-03 22:42:11 字數 2052 閱讀 1656

需求:乙個文章有人,有機構,有型別三種,查詢乙個文章額外附加三種查詢,一定是巢狀查詢,這樣就是用collection標籤,但是collection標籤只能額外查詢乙個sql,那麼怎麼查詢多個呢?當然是多個collection標籤了

"articleanduserandtypeanddeptmap" type=

"cn.hcnet2006.blog.hcnetwebsite.bean.sysarticle" extends=

"baseresultmap"

>

"userlist"

fetchtype=

"lazy"

column=

"" select=

/>

"typelist"

fetchtype=

"lazy"

column=

"" select=

/>

"deptlist"

column=

"id"

fetchtype=

"lazy"

select=

/>

<

/resultmap>

查詢sql語句

"selectall" parametertype=

"cn.hcnet2006.blog.hcnetwebsite.bean.sysarticle" resultmap=

"baseresultmap"

>

select sa.id, sa.article_name, sa.article_img_url, sa.article_intro_url, sa.article_content_url, sa.create_by, sa.create_time, sa.last_update_by, sa.last_update_time, sa.del_flag

from sys_article sa

<

if test=

" deptid != null and deptid != ''"

>

inner join sys_dept_article sda

on sda.dept_id = #

and sa.id = sda.article_id

>

<

if test=

" typeid != null and typeid != ''"

>

inner join sys_type_article sta

on sta.type_id = #

and sa.id = sta.article_id

>

<

if test=

"userid != null and userid != ''"

>

inner join sys_user_article sua

on sua.user_id = #

and sua.article_id = sa.id

>

where 1=1

<

if test=

"id != null and id != ''"

>

and sa.id = #

>

<

if test=

"articlename != null and articlename != ''"

>

and sa.article_name like concat

('%',#,

'%')

>

<

if test=

"delflag != null"

>

and sa.del_flag = #

>

<

/select>

],

"typelist":[

],"userlist":[

,]}}

多個sql語句巢狀查詢

法一 設定 connection連線 multiplestatements true 儲存查詢的sql語句的陣列 let sqlarr 儲存查詢結果的物件 let resobj async.eachseries sqlarr,function item,callback resobj item ro...

lambda函式 Collect使用(六)

collect 收集的目的就是為了下一步的轉換準備的 案例一 收集某個屬性到集合中 test public void test 收集去重 test public void test2 分組進行資料操作 test public void group 多個屬性分組 test public void te...

sql鑲嵌查詢 SQL 查詢巢狀使用

示例表如下 create table it student id int primary key auto increment,主鍵id name varchar 20 姓名 gender enum male female 性別 class id tinyint unsigned,班級號 age i...