数据库
首页 > 数据库> > 常用SQL语句写法(一)

常用SQL语句写法(一)

作者:互联网

<resultMap id="userResult" type="com.cloudwalk.shark.model.User">
<id property="id" column="ID" jdbcType="INTEGER"></id>
<result property="userName" column="user_name" jdbcType="VARCHAR"></result>
</resultMap>

<insert id="insertUser" parameterType="com.cloudwalk.shark.model.User">
INSERT INTO
t_shark_user(ID,USER_NAME)
VALUES
(
#{id},#{userName}
)
</insert>

<select id="findUserByName" parameterType="java.lang.String" resultMap="userResult">
select id,user_name as userName from t_shark_user
where 1=1
<if test=" _parameter !=null and _parameter !='' " >
and user_name = #{name,jdbcType=VARCHAR}
</if>
</select>

<select id="queryUserByName" parameterType="java.util.ArrayList" resultMap="userResult">
select id,user_name as userName from t_shark_user
where user_name in
<if test=" list !=null and list.size>0 !='' " >
<foreach collection="list" item="userName" index="index" open="(" close=")" separator=",">
#{userName}
</foreach>
</if>
</select>

标签:语句,userName,shark,name,where,user,SQL,写法,id
来源: https://www.cnblogs.com/longxok/p/10834068.html