首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

ibatis中in的用法解决思路

2013-01-23 
ibatis中in的用法select * from Table A where A.id in (XXXXXX)后面的XXXX子语句我是通过查询另外两张表

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>  

热点排行