mybatise多層集合巢狀查詢 3層

2021-10-09 17:24:05 字數 2172 閱讀 3711

1,用乙個sql,多個resultmap  一般另起乙個子map,不直接在collection中再套

每個子項都需要id才可避免子項自身被覆蓋,永遠1條

例如:id"/>

id" />

id" />

select

p.id,

p.code,

p.name,

p.long_name,

p.description,

p.type,

p.sales_flag,

p.ui_type,

p.dayweek,

p.bu,

p.has_grill,

p.daypart,

p.channel,

ttr.code tax_rate_type_code,

ttr.tax_rate,

tsp.start_date,

tsp.end_date,

tsd.start_time,

tsd.end_time,

le.content as productlongnameen,

tpg.id as grill_id,

tpg.grill_code,

tpg.name as grill_name,

tpg.grill_mode,

tpg.display_mode,

tpg.quantity,

tpg.max_quantity,

tpg.min_quantity,

tpg.grill_image,

tpgi.id grill_item_id,

tpgi.grill_item_code,

tpgi.name item_name,

tpgi.quantity item_quantity,

tpgi.is_modify,

tpgi.grill_item_image,

tpgi.is_default,

ttr1.code grill_tax_rate_type_code,

ttr1.tax_rate grill_tax_rate

from

t_product p

left join t_product_sales_period tsp on p.code = tsp.product_code

and p.data_version = tsp.data_version

left join t_product_sales_daypart tsd on p.code = tsd.product_code

and p.data_version = tsd.data_version

left join t_product_grill tpg on tpg.product_code = p.code

and tpg.data_version = p.data_version

left join t_product_grill_item tpgi on tpg.data_version = tpgi.data_version

and tpg.product_code = tpgi.product_code

and tpg.grill_code = tpgi.grill_code

left join t_master_tax_rate ttr1 on tpg.tax_rate_type_code = ttr1.

code left join t_master_tax_rate ttr on p.tax_rate_type_code = ttr.

code left join t_international_language le on le.key_code = p.code

and le.language = 'en_us'

and le.field_name = 'productlongnameen'

and le.table_name = 't_product'

and le.data_version = p.data_version

where

p.`status` = '1'

and p.data_version = #

0">

and p.code in (#)

2,用多個sql,第乙個是主sql,其他是map巢狀sql

參看:自動2層?

select

VUE多層路由巢狀

例如 在做系統時,主頁面有兩個功能 home and news 在 home 下又分為登入和註冊。首先需要將各種模板進行抽離。定義模板 id home home模板,裡面含子視口 to home login 登入router link to home zhuce 註冊router link rout...

多重 多層 巢狀迴圈

乙個迴圈結構中可以巢狀其他兩種迴圈結構,巢狀多少層和多少個都可以,一般不會超過兩層!所以多重迴圈又往往被稱為叫雙重迴圈。外層迴圈執行一次,內層迴圈執行一遍 輪。while dowhile 如果在列印圖形的時候,先看有幾行,外層迴圈控制列印幾行。再看有幾列,內層迴圈控制每列列印的內容。一會break和...

jsp中資料庫的多層while迴圈巢狀查

gly sql.executequery select yh.yhid,yh.yhmc,rctime.rctime,rctime.rclx,rctime.rcsj from rctime,yh where yh.yhid rctime.yhid while gly.next 由此 可以看出while...