简体   繁体   English

如何在myBatis中的查询中使用IN()

[英]How to use IN () in a query in myBatis

I have a requirement of using IN in a query which has a format of something like: 我要求在查询中使用IN的格式如下:

@Select("SELECT max(count) FROM whatevertable WHERE id IN (#{xyz})")
public int doSomething(List<Integer> xyz)

I tried searching but found all kinds of functions in XML but my requirement is using JAVA. 我尝试搜索,但是发现了XML中的各种功能,但我的要求是使用JAVA。 Can anyone help me with this? 谁能帮我这个?

refer this 参考这个

SELECT id, title, author   
FROM article   
WHERE id_category
IN    
<foreach item="category" index="index" collection="list"   open="("  separator=","           cose=")">     
#{category}  
</foreach>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM