beetlsql 遍历集合做in查询

Updated on in 程序人生 with 0 views and 0 comments

1.beetlsql案例

delete from a
where a.org_id_ = #orgId#
and index_id_ in (
    @for(id in indexIds){
        #id#  #text(idLP.last?"":",")#
    @}
)

sql中orgId为一个普通变量,indexIds为一个数据集合

@for(id in indexIds){@}遍历了集合中的每一个元素

#id#使用这些元素,#text中做了一个正则表达式的判断,如果当前元素是最后一个元素,则返回空字符串,不是的花就返回逗号,用于进行字符串拼接

2.其他操作

判断集合时候为空使用 isEmpty(indexIds)

isEmpty除了判断集合为空,还可以用来判断字符串时候为空,为空则返回true,否则返回false


标题:beetlsql 遍历集合做in查询
作者:wenyl
地址:http://www.wenyoulong.com/articles/2020/06/09/1591701470319.html