日期:2014-05-19  浏览次数:20705 次

ibatis中in的用法
select * from Table A where A.id in (XXXXXX)

后面的XXXX子语句我是通过查询另外两张表获取的数据。

应该咋写呢?

  <iterate conjunction="," open="(" close=")" >
       #value[]# 
   </iterate>  

这种写法,好像都是把子语句当作参数传进去的,,不符合我的需求

------解决方案--------------------
直接把查询语句写在后面不就行了?
select * from Table A where A.id in ( select id from Table B)
------解决方案--------------------
select * from tablea a where exists(select 1 from tableb b where b.id = a.id);尽量不要使用in
------解决方案--------------------
引用:
select * from Table A where A.id in (XXXXXX)

后面的XXXX子语句我是通过查询另外两张表获取的数据。

应该咋写呢?

  <iterate conjunction="," open="(" close=")" >
       #value[]# 
   </iterate>  

这种写法,好像都是把子……


-难道这样写不对?

select * from Table A where A.id in 
  <iterate conjunction="," open="(" close=")" >
       #value[]# 
   </iterate>