mybatis中sql语句问题 10
select*fromawhereidin(selectidfromb);这样的sql在mybatis中要怎么写?...
select * from a where id in (select id from b);这样的sql在mybatis中要怎么写?
展开
2个回答
展开全部
这要用到动态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>
还有就是你的悬赏太少了
<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>
还有就是你的悬赏太少了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询