一、

没用sql标签前的SQL映射代码:

<select id="findById" resultType="cn.tedu.mybatis.entity.User">
        SELECT
         id,username,password,age,phone,email
        FROM t_user
        WHERE
        id=#{id}
    </select>

使用sql标签就可以重用sql标签里面的SQL语句,

只要调用<include>标签就可以了,refid属性值填<sql>标签的id属性值

<sql id="userColumns"> id,username,password,age,phone,email</sql>
    <select id="findById" resultType="cn.tedu.mybatis.entity.User">
        SELECT
         <include refid="userColumns"></include>
        FROM t_user
        WHERE
        id=#{id}
    </select>

 

二、

 

相关文章:

  • 2021-04-09
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2022-02-03
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2021-11-19
  • 2021-11-19
相关资源
相似解决方案