mybatis中sql语句总结

//查询用户列表
@Select("select * from user")
public List<User> findAll();

//根据id查询用户
@Select("select * from user where uid=#{uid}")
public User findById(int uid);

//模糊查询
@Select("select * from user where username like '%${value}%'")    // '%${value}%'里面必须写value,不然会报错。
public List<User> search(String condition);
 
//添加用户
@Insert("insert into user(username,password,telephone,email,create_time)value(#{username},#{password},#{telephone},#{email},#{create_time}) ")
public void add(User user);

//更新用户
@Update("update user set username=#{username},password=#{password},telephone=#{telephone},email=#{email} where uid=#{uid}")
public void update(User user);

//删除用户
@Delete("delete from user where uid=#{uid}")
public void delete(int uid);
 
posted @ 2020-10-31 16:04  柯南剧场版  阅读(114)  评论(0编辑  收藏  举报