普通的: 数据库增删改查
增加:
insert into tatle values()
删除:
delete from tatle where 条件
更新
update table set 属性 where 条件
查询:
select *from table where 条件
Mybatis中的数据库增删改查
<insert id="addFile" parameterType="model.File">
INSERT INTO file(id,title,content,date) VALUES (#{id},#{title},#{content},#{date})
</insert>
<select id="findFile" parameterType="String" resultMap="File">
SELECT *FROM file WHERE content LIKE concat(concat('%',#{content}),'%')
</select>
<select id="listAll" resultMap="File">
SELECT *FROM file
</select>
<select id="findById" parameterType="int" resultMap="File">
SELECT *FROM file WHERE id=#{id}
</select>
<delete id="deleteFile" parameterType="int">
DELETE FROM file where id=#{id}
</delete>
<!--更新操作-->
<update id="updateFile" parameterType="model.File">
UPDATE file SET title=#{title},content=#{content},date=#{date} WHERE id=#{id}
</update>