1. 程式人生 > >mybatis聯合查詢(2)

mybatis聯合查詢(2)

目得:查詢評論的同時,將評論的圖片查詢出來

1.xml如下:

<span style="font-family:Microsoft YaHei;"> <select id="selectCommentGoods" parameterType="com.appdev.db.common.CriteriaParameter" resultType="map">
  select
  goods.id as goods_id,  content, startLevel, service, stream, conform, userid, goodsId,  created,
  attachment.id as attachment_id, imageName, imageUpdateName, url, commentId, createDate
  from comment_goods as goods
  left join (select * from(select * from comment_attachment order by createDate)tmp)attachment on goods.id = attachment.commentId 
  <if test="_parameter != null" >
     <include refid="sqlcriteria.util.Example_Where_Clause" />
  </if>
  order by goods.created
  </select></span>