栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

【Oracle XML 中的 in条件查询】

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【Oracle XML 中的 in条件查询】

Oracle in 条件查询 1 foreach 的参数描述

在 mapper 层或 dao 层中,参数是一个 list,所以在 XML 中的 SQL,需要 foreach 放在 in 的条件中进查询。其中 collection 是mapper层或dao的参数,item是list中的对象,index是item对象在list中的索引,open则是 list 以“(”左括号开始,item之间用逗号“,”隔开,以“)”为list结束的标志。

2 代码
select category4_id, category4_name, t1.category3_id, t1.category3_name
from tb_categoryview t1 join(
	select distinct category3_id from tb_select_devicesview
	where category2_id in
		
			#{item}
		
) t2
on t1.category3_id = t2.category3_id
and materialgroup4_name is not null
and t1.materialgroup3_name is not null
order by category4_id
3 foreach 标签

关键的SQL是:主要是对 foreach 的使用


	#{item}

4 如果 list 的 size 比较小的情况下,或确定的情况
select category4_id, category4_name, t1.category3_id, t1.category3_name
from tb_categoryview t1 join(
	select distinct category3_id from tb_select_devicesview
	where category2_id in ('A01', 'C02', 'B01')
) t2
on t1.category3_id = t2.category3_id
and materialgroup4_name is not null
and t1.materialgroup3_name is not null
order by category4_id

即 list 是确定的,可一一列举的情况。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/930296.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号