关于sql查询语句
来源:4-4 注册接口开发
小王子WL
2022-03-04 17:20:29
<select id="selectByName" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from imooc_mall_user
where username = #{userName,jdbcType=VARCHAR}
</select>上面怎么写的这么麻烦之前学习都没有这些参数,我换成前面课程的书写也没有报错
<select id="selectByName" parameterType="java.lang.String" resultMap="BaseResultMap">
select *
from imooc_mall_user
where username=#{value}
</select>那最上面写法的意义在哪里
1回答
同学你好,<include refid="Base_Column_List"/>是引入之前配置的字段,如:

<sql>标签用于定义SQL片段。<include>标签是引用,可以复用SQL片段。
select <include refid="Base_Column_List" />等同于select id, username, `password`, personalized_signature, `role`, create_time, update_time
祝学习愉快~