mybatis中sql语句问题

select * from a where id in (select id from b);这样的sql在mybatis中要怎么写?

这要用到动态sql了,首先你要改成
<resultMap type="test" id="test">
<id property="id" column="id" />
<result column="name" property="name" />
<collection property="picture" ofType="picture">
<id property="picture_id" column="id" />
<result column="product_id" property="product_id" />
<result column="img" property="picture_img" />
</collection>
</resultMap>
<select id="selecTests" resultMap="test">
select
A.id ,
B.product_id,
B.img,
A.name
from test A
LEFT JOIN
picture B ON A.id=B.product_id
</select>
还有就是你的悬赏太少了
温馨提示:内容为网友见解,仅供参考
第1个回答  2016-10-10
直接这样写就可以了追问

报错啊,兄弟,不能直接这样写。。

相似回答