本文介绍了如何在iBATIS中使用IN子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用来创建select语句。现在我想用iBATIS实现以下SQL语句:

I'm using iBATIS to create select statements. Now I would like to implement the following SQL statement with iBATIS:

SELECT * FROM table WHERE col1 IN ('value1', 'value2');

使用以下方法,语句未正确准备且没有结果返回:

With the following approach, the statement is not prepared correctly and no result returns:

SELECT * FROM table WHERE col1 IN #listOfValues#;

iBATIS似乎重组了这个列表并尝试将其解释为字符串。

iBATIS seems to restructure this list and tries to interpret it as a string.

我如何正确使用IN子句?

How can I use the IN clause correctly?

推荐答案

这是一篇回复你的博文问题:

Here's a blog post that answers your question:

<select id="select-test" resultMap="MyTableResult" parameterClass="list">
select * from my_table where col_1 in
  <iterate open="(" close=")" conjunction=",">
   #[]#
  </iterate>
</select>





List<String> list = new ArrayList<String>(3);
list.add("1");
list.add("2");
list.add("3");
List objs = sqlMapClient.queryForList("select-test",list);

这篇关于如何在iBATIS中使用IN子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 13:33