打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
MyBatis多表关联查询 – 蓝海魔方
  1. <resultMap id="BaseResultMap" type="com.lssrc.cms.dto.JobDto" >
  2. <id column="j_id" property="jId" jdbcType="VARCHAR" />
  3. <result column="j_title" property="jTitle" jdbcType="VARCHAR" />
  4. <result column="j_belong" property="jBelong" jdbcType="VARCHAR" />
  5. <result column="j_type" property="jType" jdbcType="VARCHAR" />
  6. <result column="j_content" property="jContent" jdbcType="LONGVARCHAR" />
  7. <association property="jobBelong" javaType="com.lssrc.cms.entity.JobBelong">
  8. <id column="jb_id" property="jbId" jdbcType="VARCHAR" />
  9. <result column="jb_name" property="jbName" jdbcType="VARCHAR" />
  10. </association>
  11. <association property="jobType" javaType="com.lssrc.cms.entity.JobType">
  12. <id column="jt_id" property="jtId" jdbcType="VARCHAR" />
  13. <result column="jt_name" property="jtName" jdbcType="VARCHAR" />
  14. </association>
  15. </resultMap>

在SQL中这样写就可以:

  1. <select id="selectByPage" resultMap="BaseResultMap">
  2. select
  3. *
  4. from shsj_job, shsj_job_belong, shsj_job_type
  5. where
  6. shsj_job.j_type=shsj_job_type.jt_id and
  7. shsj_job.j_belong=shsj_job_belong.jb_id
  8. order by j_id desc
  9. limit #{start},#{pageSize}
  10. </select>

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Mybatis中resultMap
MyBatis学习4
ibatis和mybatis的区别
MyBatis多表关联查询
如何细粒度地控制你的MyBatis二级缓存(mybatis
关于iBATIS的sqlmap的几点说明
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服