mybatis查询两张表的mapper文件怎么写

MyBatis中,两表查询,使用

<resultMap id="ResultMap3" type="java.util.Map">
    查询的表的字段映射,例:
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="path" property="path" jdbcType="VARCHAR"/>
<result column="file_size" property="fileSize" jdbcType="INTEGER"/>
</resultMap>

范文:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.njzykj.ms.dao.companyInfo.ZykjUnitInformationDao">
    <resultMap id="BaseResultMap" type="com.njzykj.ms.entity.companyInfo.ZykjUnitInformation">
        <!--
          WARNING - @mbggenerated
          This element is automatically generated by MyBatis Generator, do not modify.
          This element was generated on Wed May 30 16:42:45 CST 2018.
        -->
        <id column="ID" property="id" jdbcType="INTEGER"/>
        <result column="company_id" property="companyId" jdbcType="INTEGER"/>
        <result column="information_name" property="informationName" jdbcType="VARCHAR"/>
        <result column="information_content" property="informationContent" jdbcType="VARCHAR"/>
        <result column="company_floor" property="companyFloor" jdbcType="INTEGER"/>
        <result column="classfiy" property="classfiy" jdbcType="CHAR"/>
        <result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="left_lng_lat" property="leftLngLat" jdbcType="VARCHAR"/>
        <result column="right_lng_lat" property="rightLngLat" jdbcType="VARCHAR"/>
        <result column="information_message" property="informationMessage" jdbcType="VARCHAR"/>
        <result column="effect_status" property="effectStatus" jdbcType="VARCHAR"/>
    </resultMap>
    
    <resultMap id="ResultMap3" type="java.util.Map">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="path" property="path" jdbcType="VARCHAR"/>
        <result column="file_size" property="fileSize" jdbcType="INTEGER"/>
        <result column="file_desc" property="fileDesc" jdbcType="VARCHAR"/>
        <result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
        <result column="create_at" property="createAt" jdbcType="TIMESTAMP"/>
        <result column="file_name" property="fileName" jdbcType="VARCHAR"/>
    </resultMap>

    <select id="selectByCompanyId" resultMap="ResultMap3">
        select * from zykj_unit_information as a , file_store as b
        where a.company_id = #{companyId}
        AND a.parent_id = b.parent_id
        AND b.file_desc !=2
    </select>

</mapper>

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

醉梦逍遥游

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值