ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guido García Bernardo <ggb...@tid.es>
Subject Re: How to use SQL's "IN" with iBatis
Date Thu, 26 Jan 2006 08:53:07 GMT
Hi,

You can use the <iterate> tag:

String[] key = { "01" , "02", "03" };

case 1: using IN as you want

select table.column1 from table where table.column2 IN
<iterate property="key" open="(" close=")" conjunction=",">
    #key[]#
</iterate>       

case 2: using OR as an alternative

select table.column1 from table where
<iterate property="key" conjunction="OR">
    table.column2 = #key[]#
</iterate>       

Maybe there is some typo, but you get the idea.
Best regards,

anson escribió:
> Dears,
>
> Could any one tell me how to use "IN" with  iBatis?
>
> For example:
>
> case 1:
>
> String key = "01,02,03";
>
> select table.colum1 from table where table.colum2 IN (#key#)
>
> I can not get anything.
>
>
>
>
>
> case 2:
>
> String key = "01";
>
> select table.colum1 from table where table.colum2 IN (#key#)
>
> I can get the right result.
>
>
>
>
>
> case 3:
> String key = "'01'"
>
> select table.colum1 from table where table.colum2 IN (#key#)
>
> I can not get anything.
>
>
>
>
>
> How can I get right result with iBatis like this SQL:
>
> select table.colum1 from table where table.colum2 IN ('01', '02', '03');
>
> Best Regards!!
>
>
>
>
>
>   
-- 

Guido García Bernardo
have a nice wifree !

Tfn. +34 983 54 89 08
ITDEUSTO - Valladolid


Mime
View raw message